release: version 1.0.12 - Fix buffer corruption in dynbuf_append
- FIX: Copy null terminator during buffer reallocation (db->len + 1) - This fixes JSON corruption that caused double commas in output Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@ -84,8 +84,7 @@ static void dynbuf_append(dynbuf_t *db, const char *str, apr_size_t len)
|
||||
if (db->len + len >= db->capacity) {
|
||||
apr_size_t new_capacity = (db->len + len + 1) * 2;
|
||||
char *new_data = apr_palloc(db->pool, new_capacity);
|
||||
memcpy(new_data, db->data, db->len);
|
||||
new_data[db->len] = '\0';
|
||||
memcpy(new_data, db->data, db->len + 1); /* Copy including null terminator */
|
||||
db->data = new_data;
|
||||
db->capacity = new_capacity;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user