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

Douglas Creager commented on AVRO-1528:
---------------------------------------

What's the use case for this?  The reason I ask is that in C is you don't get a 
bounds check when you access an array, and so we usually don't do a bounds 
check when you access something modeled after an array either.  That way you 
get the absolute fastest performance when you're working with safe data — and 
if you're not working with safe data, it's your responsibility to perform the 
extra checks.

There was a similar request in AVRO-1237, where we decided not to do the bounds 
check in the general function for exactly this reason.  We ended up adding a 
bounds check to the file reader, though, since that function is dealing with 
unsafe data.

So instead of changing this function's precondition ("you're responsible for 
providing a valid index"), I'd suggest we find the code that violates the 
precondition and fix that.  I can also add a documentation patch, since I don't 
think there's anything that explicitly documents this precondition.

> avro_schema_enum_get returns invalid pointer for unknown indices
> ----------------------------------------------------------------
>
>                 Key: AVRO-1528
>                 URL: https://issues.apache.org/jira/browse/AVRO-1528
>             Project: 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
(v6.2#6252)

Reply via email to