Skip to content

Commit

Permalink
fix issue #38.
Browse files Browse the repository at this point in the history
  • Loading branch information
rockcarry committed Jun 2, 2021
1 parent 15e982c commit 0fa4cf8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/bmp.c
Expand Up @@ -41,6 +41,10 @@ int bmp_load(BMP *pb, char *file)
pb->width = (int)header.biWidth > 0 ? (int)header.biWidth : 0;
pb->height = (int)header.biHeight > 0 ? (int)header.biHeight : 0;
pb->stride = ALIGN(pb->width * 3, 4);
if ((long long)pb->stride * pb->height >= 0x80000000) {
printf("bmp's width * height is out of range !\n");
goto done;
}
pb->pdata = malloc((size_t)pb->stride * pb->height);
if (pb->pdata) {
pdata = (BYTE*)pb->pdata + pb->stride * pb->height;
Expand All @@ -50,7 +54,8 @@ int bmp_load(BMP *pb, char *file)
}
}

fclose(fp);
done:
if (fp) fclose(fp);
return pb->pdata ? 0 : -1;
}

Expand Down

0 comments on commit 0fa4cf8

Please sign in to comment.