Skip to content

Commit 8b1959f

Browse files
committed
Add fclose calls
1 parent 7c380ee commit 8b1959f

File tree

4 files changed

+41
-20
lines changed

4 files changed

+41
-20
lines changed

wasm/zlib/build.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Built on 2025-01-29T13:40:54Z
1+
Built on 2025-02-11T11:31:02Z
22
Toolchain versions
33
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.73 (ac676d5e437525d15df5fd46bc2c208ec6d376a3)
44
Getting zpipe.c example source...

wasm/zlib/build/zlib.js.symbols

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,25 @@
3333
32:zcfree
3434
33:__memcpy
3535
34:__memset
36-
35:ferror
37-
36:__stdio_seek
38-
37:__stdio_write
39-
38:__stdio_read
40-
39:__stdio_close
41-
40:fopen
42-
41:fread
43-
42:__fwritex
44-
43:fwrite
45-
44:__emscripten_stdout_close
46-
45:__emscripten_stdout_seek
47-
46:strchr
48-
47:__wasi_syscall_ret
49-
48:emscripten_builtin_malloc
50-
49:sbrk
51-
50:_emscripten_stack_restore
52-
51:_emscripten_stack_alloc
53-
52:emscripten_stack_get_current
54-
53:legalstub$dynCall_jiji
36+
35:fclose
37+
36:ferror
38+
37:fflush
39+
38:__stdio_seek
40+
39:__stdio_write
41+
40:__stdio_read
42+
41:__stdio_close
43+
42:fopen
44+
43:fread
45+
44:__fwritex
46+
45:fwrite
47+
46:__emscripten_stdout_close
48+
47:__emscripten_stdout_seek
49+
48:strchr
50+
49:__wasi_syscall_ret
51+
50:emscripten_builtin_malloc
52+
51:emscripten_builtin_free
53+
52:sbrk
54+
53:_emscripten_stack_restore
55+
54:_emscripten_stack_alloc
56+
55:emscripten_stack_get_current
57+
56:legalstub$dynCall_jiji

wasm/zlib/build/zlib.wasm

518 Bytes
Binary file not shown.

wasm/zlib/src/main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ int compressFile(const char* infilename, const char* outfilename)
2727
int ret = def(infile, outfile, Z_BEST_COMPRESSION);
2828
if (ret != Z_OK)
2929
zerr(ret);
30+
31+
if (fclose(infile)) {
32+
fputs("error closing input file", stderr);
33+
return 1;
34+
}
35+
if (fclose(outfile)) {
36+
fputs("error closing output file", stderr);
37+
return 1;
38+
}
3039
return ret;
3140
}
3241
int decompressFile(const char* infilename, const char* outfilename)
@@ -45,5 +54,14 @@ int decompressFile(const char* infilename, const char* outfilename)
4554
int ret = inf(infile, outfile);
4655
if (ret != Z_OK)
4756
zerr(ret);
57+
58+
if (fclose(infile)) {
59+
fputs("error closing input file", stderr);
60+
return 1;
61+
}
62+
if (fclose(outfile)) {
63+
fputs("error closing output file", stderr);
64+
return 1;
65+
}
4866
return ret;
4967
}

0 commit comments

Comments
 (0)