Skip to content

Commit 93df119

Browse files
committed
Handle to return for cloned region
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent b9afed1 commit 93df119

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/zstdruby/streaming_compress.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ rb_streaming_compress_flush(VALUE obj)
205205
struct streaming_compress_t* sc;
206206
TypedData_Get_Struct(obj, struct streaming_compress_t, &streaming_compress_type, sc);
207207
VALUE drained = no_compress(sc, ZSTD_e_flush);
208-
rb_str_cat(sc->pending, RSTRING_PTR(drained), RSTRING_LEN(drained));
209-
VALUE out = sc->pending;
210-
sc->pending = rb_str_new(0, 0);
208+
VALUE out = rb_str_dup(sc->pending);
209+
rb_str_cat(out, RSTRING_PTR(drained), RSTRING_LEN(drained));
210+
rb_str_resize(sc->pending, 0);
211211
return out;
212212
}
213213

0 commit comments

Comments
 (0)