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

Fixed bug regarding New lines in input files #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JMMackenzie
Copy link

The bug at hand involved a file which had 2 or more new lines before any other textual data. The reason for the bug was that the tokenizer was not reading anything (ie a new line), so the value of nitems being passed to realloc was 0.

The C standard states:

C90 (C++98)
Otherwise, if size is zero, the memory previously allocated at ptr is deallocated as if a call to free was made, and a null pointer is returned.

C99/C11 (C++11)
If size is zero, the return value depends on the particular library implementation: it may either be a null pointer or some other location that shall not be dereferenced.

Thus, the if(!ptr) block would always be entered resulting in a SENNA_error: "memory allocation error .."

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.

1 participant