[foreign] RFR: 8229752: Use of pointer from scope.allocateArray with 0 element cause IllegalStateException

Jorn Vernee jbvernee at xs4all.nl
Thu Aug 15 14:39:16 UTC 2019


Hi Henry,

This looks good to me! Returning NULL also follows what malloc does [1]; 
"If size is zero, the behavior is implementation defined (null pointer 
may be returned, or some non-null pointer may be returned that may not 
be used to access storage, but has to be passed to free).". So, this 
shouldn't be that surprising to users.

Cheers,
Jorn

[1] : https://en.cppreference.com/w/c/memory/malloc

On 2019-08-15 06:28, Henry Jen wrote:
> Hi,
> 
> Please review the webrev[1] for the fix is to make sure
> 
> 1. NULL pointer is returned when allocate size 0, this is to make sure
> the pointer is with null layout, so that addr() won’t fail because of
> size check.
> 2. Pointer.copy to accept NULL pointer when copying 0 bytes. This make
> sure the interoperability with any other pointers when 0 bytes is
> needed.
> 
> Cheers,
> Henry
> 
> [1] https://cr.openjdk.java.net/~henryjen/panama/8229752/0/webrev/


More information about the panama-dev mailing list