Mercurial > hg > dmlib
comparison src/dmgrowbuf.c @ 1785:86d10d5d4915
Fix case where DMGrowBuf is growing backwards and needs to be reallocated in
dmGrowBufRealloc() and the data is moved to the "end" of the newly grown
buffer. Previously we used clrsize as data size, but that is (in retrospect)
obviously incorrect. Use old buffer size instead.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 13 Jun 2018 01:39:06 +0300 |
parents | a29d38862037 |
children | 0801fd0e26cb |
comparison
equal
deleted
inserted
replaced
1784:a29d38862037 | 1785:86d10d5d4915 |
---|---|
172 // current data to the end of the buffer .. | 172 // current data to the end of the buffer .. |
173 size_t clrsize = nsize - buf->size; | 173 size_t clrsize = nsize - buf->size; |
174 DM_DBG(" clrsize=%" DM_PRIu_SIZE_T "\n", clrsize); | 174 DM_DBG(" clrsize=%" DM_PRIu_SIZE_T "\n", clrsize); |
175 if (buf->backwards) | 175 if (buf->backwards) |
176 { | 176 { |
177 memmove(buf->data + clrsize, buf->data, clrsize); | 177 memmove(buf->data + clrsize, buf->data, buf->size); |
178 buf->offs += clrsize; | 178 buf->offs += clrsize; |
179 } | 179 } |
180 | 180 |
181 // Check if we need to clear the newly allocated area? | 181 // Check if we need to clear the newly allocated area? |
182 if (clear) | 182 if (clear) |