mirror of
https://github.com/json-c/json-c.git
synced 2026-11-05 21:20:16 +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:
1 parent
1bd2e4b3ef
commit
62bb838c57
3 files changed
+49
-1
No files matched your search
@@ -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