Skip to content

Conversation

windpls
Copy link
Contributor

@windpls windpls commented Jan 26, 2015

In the original code, if the expression 'prev->val == cur->val' returns true, then prev->next will be updated and the memory 'cur' points to will be released. So, the cur = cur->next in 'for' is in fact illegal.

I fix this bug by just change cur = cur->next to cur=prev->next.

soulmachine added a commit that referenced this pull request Jan 8, 2016
fix a bug in "Remove Duplicates from Sorted List"
@soulmachine soulmachine merged commit 938534e into soulmachine:master Jan 8, 2016
@soulmachine
Copy link
Owner

An exellent fix, thank you!

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

Successfully merging this pull request may close these issues.

2 participants