Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ocr_bitmap can run out of buffer memory copying the "last font tag" #1586

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions docs/CHANGES.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- Improvement: Ignore MXF Caption Essence Container version byte to enhance SRT subtitle extraction compatibility
- New: Add tesseract page segmentation modes control with `--psm` flag
- Fix: Resolve compile-time error about implicit declarations (#1646)
- Fix: fatal out of memory error extracting from a VOB PS

0.94 (2021-12-14)
-----------------
Expand Down
2 changes: 1 addition & 1 deletion src/lib_ccx/dvd_subtitle_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ int process_spu(struct lib_cc_decode *dec_ctx, unsigned char *buff, int length,

if (ctx->append == 1)
{
memcpy(ctx->buffer + ctx->len, buff, length);
memmove(ctx->buffer + ctx->len, buff, length);
ctx->len += length;
ctx->append = 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/lib_ccx/ocr.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ char *ocr_bitmap(void *arg, png_color *palette, png_byte *alpha, unsigned char *
// realloc if memory allocated may be not enough
int length_needed = (new_text_out_iter - new_text_out) +
(line_end - line_start) +
(last_font_tag_end ? (last_font_tag_end - last_font_tag) : 0) +
length_closing_font + 32;

if (length_needed > length)
Expand Down
Loading