Skip to content

write_history silently eats IO errors in fprintf rather than failing #66

@lf-

Description

@lf-

editline/src/editline.c

Lines 1619 to 1634 in c50d4c3

int write_history(const char *filename)
{
FILE *fp;
int i = 0;
hist_alloc();
fp = fopen(filename, "w");
if (!fp)
return EOF;
while (i < H.Size)
fprintf(fp, "%s\n", H.Lines[i++]);
return fclose(fp);
}

Note that fprintf has no check on its return value so it could fail without being reported. I am unsure if the IO errors turn the FILE * into some poison that would cause the fclose() to fail, but somehow I suspect they would not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions