majensen / libneo4j-omni

Up-to-date C library and CLI for Neo4j based on libneo4j-client
Apache License 2.0
4 stars 2 forks source link

neo4j_ustring_value() returns null pointer for empty strings #10

Open johannessen opened 4 days ago

johannessen commented 4 days ago

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.

https://github.com/majensen/libneo4j-omni/blob/1151ada0fd8aa507d2e736a82074449f52df42ed/lib/src/deserialization.c#L664-L679

johannessen commented 3 days ago

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.