ソースを参照

Fix binary leak when encoding large strings

This bug was due to an interaction between two optimizations. If we
attempt to flush the buffer before any bytes are used we refused.
However, in enc_ensure we were not checking whether the buffer was
actually flushed so we would allocate a new buffer for the request.

The easiest way to encounter this issue was by encoding a raw binary
longer than 2041 bytes (i.e., `jiffy:encode(<<"stuff...">>).`).
pull/198/head
Paul J. Davis 5年前
コミット
0ba322e421
1個のファイルの変更4行の追加0行の削除
  1. +4
    -0
      c_src/encoder.c

+ 4
- 0
c_src/encoder.c ファイルの表示

@ -166,6 +166,10 @@ enc_ensure(Encoder* e, size_t req)
if(!enc_flush(e)) { if(!enc_flush(e)) {
return 0; return 0;
} }
if(e->have_buffer) {
return 1;
}
} }
for(new_size = BIN_INC_SIZE; new_size < req; new_size <<= 1); for(new_size = BIN_INC_SIZE; new_size < req; new_size <<= 1);

読み込み中…
キャンセル
保存