Commit e5039cd
committed
Fix potential memory leak if zstd_compress fails
This PR fixes a potential memory leak in the compression path.
In the current implementation, if zstd_compress returns an error, rb_raise is called immediately.
If rb_raise will be called, the subsequent ZSTD_freeCCtx(ctx) is never reached.
This change ensures that ZSTD_freeCCtx(ctx) is called before raising the exception, preventing the context leak.
Seems zstd_compress errors are rare in practice, this fix ensures safety for those edge cases.1 parent 8ae07a1 commit e5039cd
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
0 commit comments