vshCalloc function uses xalloc_oversized macro that can't take 0 as it's
second argument. If vshCalloc is called with size 0, virsh ends with a
floating point exception.
This patch changes vshCalloc to return NULL if no memory is requested.
---
tools/virsh.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 53d1825..d3d5c6a 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -460,6 +460,9 @@ _vshCalloc(vshControl *ctl, size_t nmemb, size_t size, const char
*filename, int
{
char *x;
+ if (!size)
+ return NULL;
+
if (!xalloc_oversized(nmemb, size) &&
VIR_ALLOC_N(x, nmemb * size) == 0)
return x;
--
1.7.8.6