]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: fix stepping on unallocated memory
authorSage Weil <sage.weil@dreamhost.com>
Thu, 8 Dec 2011 16:01:12 +0000 (08:01 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Thu, 8 Dec 2011 16:06:26 +0000 (08:06 -0800)
If size is 0 we can't write here.

Reported-by: pankaj singh <psingh.ait@gmail.com>
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/crush/builder.c

index c3382692c99ccd6efaf7626a19931960073c5314..ce1f21bc449f54bb68d193ced1726a6ec6b3f79a 100644 (file)
@@ -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<size; i++) {
                for (j=0; j<i; j++) {
                        if (weights[i] < weights[reverse[j]]) {