[ 
https://issues.apache.org/jira/browse/AVRO-1528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16703837#comment-16703837
 ] 

ASF GitHub Bot commented on AVRO-1528:
--------------------------------------

dkulp closed pull request #398: AVRO-1528. C: Applied patch for enum bounds.
URL: https://github.com/apache/avro/pull/398
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/lang/c/src/avro/schema.h b/lang/c/src/avro/schema.h
index 41dd8ea48..31d5281a4 100644
--- a/lang/c/src/avro/schema.h
+++ b/lang/c/src/avro/schema.h
@@ -61,6 +61,7 @@ int avro_schema_enum_get_by_name(const avro_schema_t enump,
                                 const char *symbol_name);
 int avro_schema_enum_symbol_append(const avro_schema_t
                                   enump, const char *symbol);
+int avro_schema_enum_number_of_symbols(const avro_schema_t enump);
 
 avro_schema_t avro_schema_fixed(const char *name, const int64_t len);
 avro_schema_t avro_schema_fixed_ns(const char *name, const char *space,
diff --git a/lang/c/src/schema.c b/lang/c/src/schema.c
index 3ade1140e..ec2364e9f 100644
--- a/lang/c/src/schema.c
+++ b/lang/c/src/schema.c
@@ -574,6 +574,16 @@ avro_schema_enum_symbol_append(const avro_schema_t 
enum_schema,
        return 0;
 }
 
+int
+avro_schema_enum_number_of_symbols(const avro_schema_t enum_schema)
+{
+       check_param(EINVAL, is_avro_schema(enum_schema), "enum schema");
+       check_param(EINVAL, is_avro_enum(enum_schema), "enum schema");
+
+       struct avro_enum_schema_t *enump = avro_schema_to_enum(enum_schema);
+       return enump->symbols->num_entries;
+}
+
 int
 avro_schema_record_field_append(const avro_schema_t record_schema,
                                const char *field_name,


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> avro_schema_enum_get returns invalid pointer for unknown indices
> ----------------------------------------------------------------
>
>                 Key: AVRO-1528
>                 URL: https://issues.apache.org/jira/browse/AVRO-1528
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: c
>    Affects Versions: 1.7.6
>            Reporter: Jeno I. Hajdu
>            Priority: Trivial
>         Attachments: AVRO-1528.patch
>
>
> When avro_schema_enum_get() is called with invalid indices it returns an 
> invalid pointer instead of NULL, this leads to segfaults. Similar problem is 
> already handled in avro_schema_enum_get_by_name() when converting the other 
> way round, avro_schema_enum_get() could handle it likewise.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to