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

fix a list infinite loop bug #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

flizzywine
Copy link

@flizzywine flizzywine commented Apr 2, 2018

imagine such code:
list_t ls1 = alloc_object(1);
cons(2, ls1);
these code will make an infinite loop, because when alloc an object,
didn't modify its next, so it naturally links with object allocated later.
In this case, 2 will be next of 1, but when cons 2 and 1, 2 becomes prev of 1.
to avoid this bug, fix alloc_object() function's bug by adding some statements.

imagine such code:
list_t ls1 = alloc_object(1);
cons(2, ls1);
these code will make an infinite loop, because NEXT(NEXT(ls1) ) == ls.
to avoid this bug, fix the alloc_object() function, add some statements.
@gzc
Copy link
Owner

gzc commented Apr 2, 2018

Is the variable new_obj same as new ?

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