fix OOB fwrite

master
Avril 4 years ago
parent 5b10589dcd
commit bbbeec9ed7
Signed by: flanchan
GPG Key ID: 284488987C31F630

4
.gitignore vendored

@ -0,0 +1,4 @@
bits-*
perf.*
*.svg
obj/

@ -20,7 +20,7 @@ static int fwrite_all(const void* buf, size_t esz, size_t num, FILE* out)
register size_t w, done=0; register size_t w, done=0;
register size_t fsz = esz * num; register size_t fsz = esz * num;
const char* tbuf = (const char*)buf; const char* tbuf = (const char*)buf;
while( (w = fwrite(tbuf+done, 1, fsz, out)) > 0 && done < fsz) done+=w; while( (w = fwrite(tbuf+done, 1, fsz-done, out)) > 0 && done < fsz) done+=w;
if (done!=fsz) return 0; if (done!=fsz) return 0;
else return 1; else return 1;
} }

Loading…
Cancel
Save