Skip to content

Commit d362fbf

Browse files
committed
FIx finalization of finish for zstd streaming compression
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 81e3cea commit d362fbf

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
@@ -217,9 +217,9 @@ rb_streaming_compress_finish(VALUE obj)
217217
struct streaming_compress_t* sc;
218218
TypedData_Get_Struct(obj, struct streaming_compress_t, &streaming_compress_type, sc);
219219
VALUE drained = no_compress(sc, ZSTD_e_end);
220-
rb_str_cat(sc->pending, RSTRING_PTR(drained), RSTRING_LEN(drained));
221-
VALUE out = sc->pending;
222-
sc->pending = rb_str_new(0, 0);
220+
VALUE out = rb_str_dup(sc->pending);
221+
rb_str_cat(out, RSTRING_PTR(drained), RSTRING_LEN(drained));
222+
rb_str_resize(sc->pending, 0);
223223
return out;
224224
}
225225

0 commit comments

Comments
 (0)