Skip to content

Return the ungetc() character from fread() - #163

Open
rosenrost wants to merge 2 commits into
freemint:masterfrom
rosenrost:fix/return-the-ungetc-character-from-fread
Open

rosenrost wants to merge 2 commits into
freemint:masterfrom
rosenrost:fix/return-the-ungetc-character-from-fread

Conversation

@rosenrost

Copy link
Copy Markdown
Contributor

fread() read directly from the file handle and ignored a character pushed back with ungetc().

Both functions divided the number of transferred bytes by size to
compute the number of items, which crashed with a division by zero
when called with size == 0. Return 0 early if size or nmemb is 0,
as required by the C standard.
fread() read directly from the file handle and ignored a character
pushed back with ungetc(), which was then returned by a later fgetc()
out of order.
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