bugfix in hl_buffer_str_sub which might cause input string to be gc'ed
@@ -65,6 +65,7 @@ static void buffer_append_new( hl_buffer *b, const uchar *s, int len ) {
HL_PRIM void hl_buffer_str_sub( hl_buffer *b, const uchar *s, int len ) {
stringitem it;
+ int offset = 0;
if( s == NULL || len <= 0 )
return;
b->totlen += len;
@@ -78,11 +79,11 @@ HL_PRIM void hl_buffer_str_sub( hl_buffer *b, const uchar *s, int len ) {
} else {
memcpy(it->str + it->len,s,free<<1);
it->len += free;
- s += free;
+ offset = free;
len -= free;
}
}
- buffer_append_new(b,s,len);
+ buffer_append_new(b,s + offset,len);
}
HL_PRIM void hl_buffer_str( hl_buffer *b, const uchar *s ) {
