On Sat, Dec 01, 2018 at 11:10:24PM +0000, Richard W.M. Jones wrote:
+int
+bitmap_resize (struct bitmap *bm, uint64_t new_size)
+{
+ uint8_t *new_bitmap;
+ const size_t old_bm_size = bm->size;
+ uint64_t new_bm_size_u64;
+ size_t new_bm_size;
+
+ new_bm_size_u64 = DIV_ROUND_UP (new_size, bm->blksize * 8 / bm->bpb);
+ if (new_bm_size_u64 > SIZE_MAX) {
+ nbdkit_error ("bitmap too large for this architecture");
+ return -1;
+ }
+ new_bm_size = (size_t) new_bm_size_u64;
+
+ new_bitmap = realloc (bm->bitmap, new_bm_size);
One thing I've noticed is this allocation is never freed. In fact the
same thing happens in the old code. Why doesn't valgrind pick that
up? Needs some investigation ...
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW