Skip to content

a core when error string with ” #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chinchilla-forest opened this issue Apr 27, 2018 · 1 comment
Closed

a core when error string with ” #262

chinchilla-forest opened this issue Apr 27, 2018 · 1 comment

Comments

@chinchilla-forest
Copy link

chinchilla-forest commented Apr 27, 2018

Hi i find a core when use error string to a parser。
My code is:
char my_string[1024] = "{\"name\": \"Jack \" Nimble\"}";
printf("string is %s\n",my_string);
cJSON *root = cJSON_Parse(my_string);
if(root ==NULL)
printf("parse error");

and the result is :
string is {"name": "Jack " Nimble"}
Segmentation fault

it is core in cJSON *root = cJSON_Parse(my_string);

and if i change the string to right json:
char my_string[1024] = "{\"name\: \"Jack Nimble\"}";
it is work well。

@chinchilla-forest
Copy link
Author

sorry I am wrong。For my question, the compiler should optimize my code. My subsequent code will still call root, and he may be executed before the error is printed.

@FSMaxB FSMaxB closed this as completed Apr 27, 2018
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

No branches or pull requests

2 participants