I noticed that the pointer returned by malloc wasn't checked against nullptr. This branch checks for nullptr and returns JSON_ALLOCATION_FAILURE.
When I ran the test-suite under Valgrind, it reported memory leaks.
==5501== HEAP SUMMARY:
==5501== in use at exit: 2,866 bytes in 43 blocks
==5501== total heap usage: 65 allocs, 22 frees, 92,978 bytes allocated
==5501==
==5501== LEAK SUMMARY:
==5501== definitely lost: 2,866 bytes in 43 blocks
==5501== indirectly lost: 0 bytes in 0 blocks
==5501== possibly lost: 0 bytes in 0 blocks
==5501== still reachable: 0 bytes in 0 blocks
==5501== suppressed: 0 bytes in 0 blocks
==5501== Rerun with --leak-check=full to see details of leaked memory
==5501==
==5501== For counts of detected and suppressed errors, rerun with: -v
==5501== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Gason proper wasn't the problem. By freeing the pointer returned by strcpy in test-suite.cpp, Valgrind reports no leaks.
==5641== HEAP SUMMARY:
==5641== in use at exit: 0 bytes in 0 blocks
==5641== total heap usage: 65 allocs, 65 frees, 92,978 bytes allocated
==5641==
==5641== All heap blocks were freed -- no leaks are possible
==5641==
==5641== For counts of detected and suppressed errors, rerun with: -v
==5641== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
This branch addresses two memory issues.
Gason proper wasn't the problem. By freeing the pointer returned by strcpy in test-suite.cpp, Valgrind reports no leaks.