Skip to content

Commit

Permalink
Add fopen check to data package.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabordemooij committed Aug 6, 2024
1 parent 2f644c2 commit 5bee774
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion plugins/media/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -4074,11 +4074,18 @@ ctr_object* ctr_package_add(ctr_object* myself, ctr_argument* argumentList) {
ctr_internal_object_property(fileObject, "path", NULL)
)
);
FILE* f = fopen(path, "rb");
if (f == NULL) {
ctr_error( CTR_ERR_OPEN, errno );
ctr_heap_free(path);
ctr_heap_free(pkgpath);
fclose(outfile);
return CtrStdNil;
}
fwrite(path, 1, strlen(path), outfile);
fwrite("\0", 1 , 1, outfile);
next_entry_at = ftell(outfile);
fwrite("\0\0\0\0\0\0\0\0", 8, 1, outfile);
FILE* f = fopen(path, "rb");
buffer = calloc(1,CHUNK_SIZE);
clearerr(f);
while(!feof(f)) {
Expand Down

0 comments on commit 5bee774

Please sign in to comment.