vivkin / gason

Lightweight and fast JSON parser for C++
MIT License
338 stars 51 forks source link

Null check #16

Closed tendervittles closed 9 years ago

tendervittles commented 9 years ago

This branch addresses two memory issues.

==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)