BUG/MEDIUM: htx: Set the right start-line offset after a defrag
The offset was always wrong after an HTX defragmentation because the wrong
address was used and because the update could occcur several time on the same
defragmentation.
diff --git a/src/htx.c b/src/htx.c
index 1f0ebeb..5ca7b7e 100644
--- a/src/htx.c
+++ b/src/htx.c
@@ -28,6 +28,7 @@
struct htx_blk *newblk, *oldblk;
uint32_t new, old;
uint32_t addr, blksz;
+ int32_t sl_off = -1;
if (!htx->used)
return NULL;
@@ -49,19 +50,20 @@
newblk->info = oldblk->info;
blksz = htx_get_blksz(oldblk);
+ /* update the start-line offset */
+ if (htx->sl_off == oldblk->addr)
+ sl_off = addr;
+
memcpy((void *)tmp->blocks + addr, htx_get_blk_ptr(htx, oldblk), blksz);
new++;
addr += blksz;
- /* update the start-line offset */
- if (htx->sl_off == oldblk->addr)
- htx->sl_off = addr;
-
/* if <blk> is defined, set its new location */
if (blk != NULL && blk == oldblk)
blk = newblk;
} while (new < htx->used);
+ htx->sl_off = sl_off;
htx->wrap = htx->used;
htx->front = htx->tail = new - 1;
memcpy((void *)htx->blocks, (void *)tmp->blocks, htx->size);