Offset sanity checks

This commit is contained in:
surkeh
2018-04-19 05:58:35 -07:00
parent 2977274f93
commit 889a3e44a6
6 changed files with 15 additions and 7 deletions

View File

@@ -45,6 +45,7 @@ void write(const char *filename,
fclose(out);
if (written == 0) {
perror("write error");
exit(4);
}
}
}
@@ -61,6 +62,7 @@ void append(const char *filename, const char *t, unsigned size) {
fclose(out);
if (written == 0) {
perror("write error");
exit(4);
}
}
}

View File

@@ -57,8 +57,8 @@ void writemesh(const struct MeshHeader *mh,
}
void extractmeshes(const char *filedata,
unsigned int filesize,
const char *filename) {
const char *filename,
unsigned int filesize) {
if (filedata == NULL || filesize <= 0) {
return;
}
@@ -83,7 +83,7 @@ int main(int argc, char ** argv) {
char *f = argv[1];
unsigned int bufsize = 0;
char *buffer = loadfile(f, &bufsize);
extractmeshes(buffer, bufsize, f);
extractmeshes(buffer, f, bufsize);
free(buffer);
return 0;
}