From 19de49763acd788b6317dc8bb89d09e3a051b7fa Mon Sep 17 00:00:00 2001 From: kdrag0n Date: Tue, 21 Jan 2020 08:19:19 -0800 Subject: [PATCH] [FIX] Fix minor memory leak in OCR code (#1206) * ocr: Fix minor memory leak Detected by Valgrind: ==1203168== 2,880 bytes in 57 blocks are definitely lost in loss record 3 of 4 ==1203168== at 0x483877F: malloc (vg_replace_malloc.c:309) ==1203168== by 0x51ADBEE: strdup (in /usr/lib/libc-2.30.so) ==1203168== by 0x24D1F8: ocr_bitmap (ocr.c:569) ==1203168== by 0x24E25B: ocr_rect (ocr.c:907) ==1203168== by 0x284832: write_dvb_sub (dvb_subtitle_decoder.c:1665) ==1203168== by 0x284B7A: dvbsub_handle_display_segment (dvb_subtitle_decoder.c:1720) ==1203168== by 0x285024: dvbsub_decode (dvb_subtitle_decoder.c:1828) ==1203168== by 0x2406AF: process_data (general_loop.c:648) ==1203168== by 0x2416D0: general_loop (general_loop.c:1025) ==1203168== by 0x1AC89A: api_start (ccextractor.c:214) ==1203168== by 0x16EC03: main (ccextractor.c:536) * changes: Document OCR memory leak fix --- docs/CHANGES.TXT | 1 + src/lib_ccx/ocr.c | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/CHANGES.TXT b/docs/CHANGES.TXT index fe593250..27638a92 100644 --- a/docs/CHANGES.TXT +++ b/docs/CHANGES.TXT @@ -21,6 +21,7 @@ - Fix: Change inet_ntop to inet_ntoa for Windows XP compatibility - FIX: Added an option to disable timestamps for WebVTT (In response to issue #1127) - FIX: Add FT_Done_Face to destroy face objects after they're used +- Fix: Fixed a small OCR memory leak 0.88 (2019-05-21) ----------------- diff --git a/src/lib_ccx/ocr.c b/src/lib_ccx/ocr.c index edfe9cca..4aded348 100644 --- a/src/lib_ccx/ocr.c +++ b/src/lib_ccx/ocr.c @@ -565,6 +565,7 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i memset(text_out,0,strlen(text_out_copy)+strlen(substr)+1); strcpy(text_out,substr); strcpy(text_out+strlen(substr),text_out_copy); + free(text_out_copy); written_tag = 1; } free(substr);