MojoJson
MojoJson copied to clipboard
null def in function Destory
test.c: char* jstr = ":#@$^^&^("; JsonValue value = AJson->Parse(jstr); if(value != NULL) AJson->Destroy(value);
================================================================= ==2239161==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x564852e30c19 bp 0x7fff7edbef40 sp 0x7fff7edbef10 T0) ==2239161==The signal is caused by a READ memory access. ==2239161==Hint: address points to the zero page. #0 0x564852e30c19 in Destroy /opt1/software/MojoJson/Json.c:404 #1 0x564852e30cee in Destroy /opt1/software/MojoJson/Json.c:411 #2 0x564852e34333 in easyloop /opt1/software/MojoJson/test.c:10 #3 0x564852e44355 in main /opt1/software/betafuzz/srap/wrapentry.c:98 #4 0x7f587147ad8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 #5 0x7f587147ae3f in __libc_start_main_impl ../csu/libc-start.c:392 #6 0x564852e2f994 in _start (/opt1/software/MojoJson/test+0x4994)
I tested your code with Xcode, and found an error:
Initializing 'JsonValue' with an expression of incompatible type 'JsonValue *'; dereference with *
Check the API of JsonValue:
JsonValue* (*Parse) (const char* jsonString);
So I changed the code to:
JsonValue* value = AJson->Parse(jstr);
But got a runtime error:
Invalid json value type, error char = :
Now the problem is that the string is not a valid json format:
char* jstr = ":#@$^^&^(";