Merge pull request #3592 from aaronjanse/allocation_typo

fix allocation typo
This commit is contained in:
Kovid Goyal 2021-05-08 15:10:10 +05:30 committed by GitHub
commit 7c48db7da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -306,7 +306,7 @@ png_path_to_bitmap(const char* path, uint8_t** data, unsigned int* width, unsign
unsigned char *buf = malloc(capacity); unsigned char *buf = malloc(capacity);
if (!buf) { log_error("Out of memory reading PNG file at: %s", path); fclose(fp); return false; } if (!buf) { log_error("Out of memory reading PNG file at: %s", path); fclose(fp); return false; }
while (!feof(fp)) { while (!feof(fp)) {
if (pos - capacity < 1024) { if (capacity - pos < 1024) {
capacity *= 2; capacity *= 2;
unsigned char *new_buf = realloc(buf, capacity); unsigned char *new_buf = realloc(buf, capacity);
if (!new_buf) { if (!new_buf) {