mirror of
https://github.com/json-c/json-c.git
synced 2026-09-07 16:46:50 +08:00
printbuf: preserve self-append sources across growth
When the appended data points into the printbuf itself, growing the buffer may invalidate the source pointer before it is copied. Preserve the source offset across realloc and use memmove for internal overlap.
This commit is contained in:
@@ -21,6 +21,9 @@ Append to just after resize: 32, [XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]
|
||||
Buffer size after printbuf_strappend(): 16, [XXXXXXXXXXXXXXXX]
|
||||
test_printbuf_memappend: end test
|
||||
========================================
|
||||
test_printbuf_self_append: starting test
|
||||
test_printbuf_self_append: end test
|
||||
========================================
|
||||
test_sprintbuf: starting test
|
||||
Buffer length: 0
|
||||
sprintbuf to just after resize(31+1): 32, [XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX], strlen(buf)=32
|
||||
|
||||
Reference in New Issue
Block a user