Skip to contentSkip to conversation

e2fsck: show size requested when memory allocation fails

PATCH Applied Eric Sandeen 2 participants 2 messages Jan 7, 2013 – Jan 8, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 e2fsck: show size requested when memory allocation fails

"e2fsck: Can't allocate dx_block info array"
is only so helpful - it'd be nice to know how much it tried to allocate.

In particular, since I think malloc(0) can return NULL, it'd be nice to know if maybe we passed in an uninitialized (or 0-initialized) size.

---

e2fsck/util.c +2 -1
index a808eec..6242954 100644
@@ -121,7 +121,8 @@ void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
 #endif
 	ret = malloc(size);
 	if (!ret) {
-		sprintf(buf, "Can't allocate %s\n", description);
+		sprintf(buf, "Can't allocate %u bytes for %s\n",
+			size, description);
 		fatal_error(ctx, buf);
 	}
 	memset(ret, 0, size);
#1 lore raw
Quoted 8 lines · Eric Sandeen

"e2fsck: Can't allocate dx_block info array"
is only so helpful - it'd be nice to know how much it tried to allocate.

In particular, since I think malloc(0) can return NULL, it'd be nice to know if maybe we passed in an uninitialized (or 0-initialized) size.

Thanks, applied.

- Ted