Store the old used size instead of the precomputed address, as
varbufextend might change the buffer from under us.
+2008-06-19 Guillem Jover <guillem@debian.org>
+
+ * lib/varbuf.c (varbufdupc): Store the old used size instead of the
+ precomputed address, as varbufextend might change the buffer from
+ under us.
+
2008-06-17 Guillem Jover <guillem@debian.org>
* scripts/dpkg-divert.pl: Do not silently force --rename on --remove.
}
void varbufdupc(struct varbuf *v, int c, ssize_t n) {
- char *b = v->buf + v->used;
+ size_t old_used = v->used;
+
v->used += n;
if (v->used >= v->size) varbufextend(v);
- memset(b, c, n);
+ memset(v->buf + old_used, c, n);
}
int varbufprintf(struct varbuf *v, const char *fmt, ...) {