core: mem/f_malloc - explicit set to 0 for bit shifting greater than size
authorDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 27 Jul 2017 07:07:09 +0000 (09:07 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 27 Jul 2017 07:07:09 +0000 (09:07 +0200)
src/core/mem/f_malloc.c

index 89985a4..1840378 100644 (file)
@@ -122,7 +122,8 @@ inline static int fm_bmp_first_set(struct fm_block* qm, int start)
                                return (start-bit+r);
                }
 #endif
-               v=qm->free_bitmap[bmp_idx]>>(bit+1);
+               if((bit+1) < 8*sizeof(v)) v=qm->free_bitmap[bmp_idx]>>(bit+1);
+               else v = 0;
                return start+1+bit_scan_forward((unsigned long)v);
        }
        for (r=bmp_idx+1;r<FM_HASH_BMP_SIZE; r++){