Skip to content
Snippets Groups Projects
Commit 34588467 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

fseek() after ftruncate()

Ensure the stream is in a meaningful place.
Fixes a bug, but one we're unlikely to have ever seen the way we use
this.
parent a71d6b2c
No related branches found
No related tags found
No related merge requests found
Pipeline #8005 passed
...@@ -2909,8 +2909,11 @@ bool iniWriteFile(FILE* fp, const str_list_t list) ...@@ -2909,8 +2909,11 @@ bool iniWriteFile(FILE* fp, const str_list_t list)
pos = ftell(fp); pos = ftell(fp);
if (pos == -1) if (pos == -1)
return false; return false;
if (chsize(fileno(fp), pos) != 0) /* truncate */ if (chsize(fileno(fp), pos) != 0) { /* truncate */
fseek(fp, 0, SEEK_END);
return false; return false;
}
fseek(fp, 0, SEEK_END);
return count == strListCount(list); return count == strListCount(list);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment