From ca002a3389877f5e150659649e27e7ae59d7d402 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 8 Dec 2011 08:01:12 -0800 Subject: [PATCH] crush: fix stepping on unallocated memory If size is 0 we can't write here. Reported-by: pankaj singh Signed-off-by: Sage Weil --- src/crush/builder.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/crush/builder.c b/src/crush/builder.c index c3382692c99cc..ce1f21bc449f5 100644 --- a/src/crush/builder.c +++ b/src/crush/builder.c @@ -317,7 +317,8 @@ int crush_calc_straw(struct crush_bucket_straw *bucket) /* reverse sort by weight (simple insertion sort) */ reverse = malloc(sizeof(int) * size); - reverse[0] = 0; + if (size) + reverse[0] = 0; for (i=1; i