mirror of
https://github.com/lh3/minimap2.git
synced 2026-10-02 15:58:11 +08:00
Avoid NULL pointer dereference (#1154)
If the allocated region is 0 bytes then it's unsafe to dereference it. Fixes #1147.
This commit is contained in:
@@ -192,6 +192,7 @@ int32_t mm_idx_cal_max_occ(const mm_idx_t *mi, float f)
|
|||||||
if (f <= 0.) return INT32_MAX;
|
if (f <= 0.) return INT32_MAX;
|
||||||
for (i = 0; i < 1<<mi->b; ++i)
|
for (i = 0; i < 1<<mi->b; ++i)
|
||||||
if (mi->B[i].h) n += kh_size((idxhash_t*)mi->B[i].h);
|
if (mi->B[i].h) n += kh_size((idxhash_t*)mi->B[i].h);
|
||||||
|
if (n == 0) return INT32_MAX;
|
||||||
a = (uint32_t*)malloc(n * 4);
|
a = (uint32_t*)malloc(n * 4);
|
||||||
for (i = n = 0; i < 1<<mi->b; ++i) {
|
for (i = n = 0; i < 1<<mi->b; ++i) {
|
||||||
idxhash_t *h = (idxhash_t*)mi->B[i].h;
|
idxhash_t *h = (idxhash_t*)mi->B[i].h;
|
||||||
|
|||||||
Reference in New Issue
Block a user