Fix memory leaks (#1511)

This commit is contained in:
Carlos Fernandez Sanz
2023-03-21 21:13:42 -07:00
parent f21d9e8737
commit 77b9696a37
2 changed files with 5 additions and 3 deletions

View File

@@ -1600,7 +1600,9 @@ static int write_dvb_sub(struct lib_cc_decode *dec_ctx, struct cc_subtitle *sub)
break;
}
rect->data1 = malloc(1024);
if (rect->data1 == NULL) {
rect->data1 = malloc(1024);
}
memset(rect->data1, 0, 1024);
memcpy(rect->data1, clut_table, (1 << region->depth) * sizeof(uint32_t));
assert(((1 << region->depth) * sizeof(uint32_t)) <= 1024);

View File

@@ -672,14 +672,14 @@ char *ocr_bitmap(void *arg, png_color *palette, png_byte *alpha, unsigned char *
line_start = line_end + 1;
}
*new_text_out_iter = '\0';
free(text_out);
freep(&text_out);
text_out = new_text_out;
}
}
TessResultIteratorDelete(ri);
}
// End Color Detection
freep(&text_out);
boxDestroy(&crop_points);
pixDestroy(&pix);