Skip to content
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

List split not initialising fully. #322

Closed
andysCaplin opened this issue Dec 20, 2018 · 3 comments
Closed

List split not initialising fully. #322

andysCaplin opened this issue Dec 20, 2018 · 3 comments

Comments

@andysCaplin
Copy link

sort_list() isn't initialising the previous pointer at the start of the second list to NULL.

@andysCaplin
Copy link
Author

I tried to create a PR and couldn't the fix is in cJSON_Utils.c - just added line 502 below

498 if ((second != NULL) && (second->prev != NULL))
499 {
500 /* Split the lists */
501 second->prev->next = NULL;
502 second->prev = NULL;
503 }

@FSMaxB
Copy link
Collaborator

FSMaxB commented Dec 20, 2018

Thanks. I fixed this in 1.7.10

@andysCaplin
Copy link
Author

Cheers for implementing the fix.

The prev from that element did end up getting traversed in one of my tests and it was pointing at freed memory - valgrind caught it.

The test did a sort and the element with the bad previous pointer ended up as the 1st element. The problem happened when I did a remove operation on it.

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