You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, for zero-length strings, no memory is allocated for the ustring field upon deserialisation. As a consequence, neo4j_ustring_value() returns a null pointer.
When creating new Perl values through API functions like newSVpv() or hv_store(), const char* values are internally copied into memory that is managed by Perl itself. Manually allocating a buffer isn't necessary. Our neo4j_string_to_alloc_str() function does allocate a buffer and never frees it, causing a leak. neo4j_ustring_value() should be used instead.
However, neo4j_ustring_value() currently doesn't return a valid pointer for empty strings, so we need to special-case that. (majensen/libneo4j-omni#10)
When returning SVs from an XSUB, assigning them to a Perl variable will increment their ref count, which causes a leak unless the SV on the stack is mortal. If the SV* typemap is used, they become mortal automatically when they are returned. However, when instead pushing SVs onto the value stack manually, the SVs need to be mortalised manually as well.
I was thinking maybe there should be a const char * const with the empty string. neo4j_ustring_value() could then simply return that pointer for a zero-length string. Checking the string length would have a slight overhead though.
According to the documentation,
neo4j_ustring_value()
always returns a valid pointer for a string.https://majensen.github.io/libneo4j-omni/neo4j-client-doxy.html#_CPPv419neo4j_ustring_value13neo4j_value_t
However, for zero-length strings, no memory is allocated for the
ustring
field upon deserialisation. As a consequence,neo4j_ustring_value()
returns a null pointer.libneo4j-omni/lib/src/deserialization.c
Lines 664 to 679 in 1151ada
The text was updated successfully, but these errors were encountered: