News for hackers. Stuff that matters.
Re:Show HN: Parson, lighweight json parser in C by halayli on Sunday October 28, 2012 @02:39PM (#4709597)
you are calling realloc and assigning the value directly before checking the return value. realloc can fail and return NULL and you'll overwrite the previous pointer which will cause a memory leak.

I don't see why you duplicated strndup in parson_strndup.

https://github.com/kgabis/parson/blob/master/parson.c#L129

parson_strdup can return NULL and this statement will fail silently.

Re:Show HN: Parson, lighweight json parser in C by thomaslee on Sunday October 28, 2012 @02:53PM (#4709636)
strndup is part of the "standard", but not present on some platforms unfortunately. :( I can't think of a modern C runtime that doesn't offer strdup, though.

The realloc check is good advice -- take heed, OP. :)

Re:Show HN: Parson, lighweight json parser in C by kgabis on Sunday October 28, 2012 @03:56PM (#4709794)
Realloc, strdup and strndup errors are handled as of now :) (https://github.com/kgabis/parson/commit/ee9be98974b3fdac0be1...) And yes, I've written my own strndup because it's "relatively new".
Re:Show HN: Parson, lighweight json parser in C by halayli on Sunday October 28, 2012 @03:02PM (#4709659)
True, strndup is relatively new (~7 years) to POSIX standard.