Skip to content

Commit 9804097

Browse files
authored
Merge pull request #125 from Watson1978/fix-leak2
Fix memory leak with non-String object
2 parents 20f4b8c + 317a6ae commit 9804097

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/zstdruby/zstdruby.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ static VALUE rb_compress(int argc, VALUE *argv, VALUE self)
1414
VALUE kwargs;
1515
rb_scan_args(argc, argv, "10:", &input_value, &kwargs);
1616

17+
StringValue(input_value);
18+
1719
ZSTD_CCtx* const ctx = ZSTD_createCCtx();
1820
if (ctx == NULL) {
1921
rb_raise(rb_eRuntimeError, "%s", "ZSTD_createCCtx error");
2022
}
2123

2224
set_compress_params(ctx, kwargs);
2325

24-
StringValue(input_value);
2526
char* input_data = RSTRING_PTR(input_value);
2627
size_t input_size = RSTRING_LEN(input_value);
2728

0 commit comments

Comments
 (0)