Skip to content

Fix reliance on undefined behaviour and other Linux test issues#30

Merged
johannessen merged 5 commits intomainfrom
tests-linux
Oct 19, 2025
Merged

Fix reliance on undefined behaviour and other Linux test issues#30
johannessen merged 5 commits intomainfrom
tests-linux

Conversation

@johannessen
Copy link
Collaborator

Resolves #15.

johannessen and others added 5 commits October 2, 2025 14:26
Co-authored-by: npc1054657282 <npc1054657282@users.noreply.github.com>
This changes the interface for the constructors neo4j_node(), neo4j_relationship(), neo4j_unbound_relationship(); but these are internal functions, only called from struct_deserialize(). So this change doesn't affect the public API.

For Bolt v3/v4, which don't have element IDs, struct_deserialize() generates a replacement string.
Passing a null pointer as buffer to strftime() is undefined behaviour in ISO C, even though many standard library implementations allow it, treating it like a zero-length buffer.

Our documentation of neo4j_ntostring() never mentions that you can pass a null pointer as buffer. Instead, it says that a pointer must be "a buffer", implying that NULL would be a usage error. However, it looks like NULL was in fact always supported, all the way back to the beginnings of libneo4j-client.

This change special-cases zero-length buffers in the temporal *_str functions and updates the documentation to indicate that NULL is a supported value for the buffer pointer.
The spatial and temporal *_fprint functions relied on the positive return value of fputs() being the number of bytes written, but that's undefined behaviour in ISO C.

This change replaces fputs() with fprintf().
@johannessen
Copy link
Collaborator Author

Neo4j-Client-0.55-TRIAL

@johannessen johannessen merged commit 05a3b74 into main Oct 19, 2025
4 checks passed
@johannessen johannessen deleted the tests-linux branch October 19, 2025 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests workflow fails for Linux

1 participant