Skip to content

Commit 9e2a594

Browse files
authored
fix(ocr_bitmap): out of buffer memory copying the "last font tag" & use memmove (#1586)
* ASAN: process_spu copies overlapping buffers * ocr_bitmap: Make sure there is enough room for the last_font_tag * Update CHANGES.TXT * Baseline formatting fixes * fixup! Baseline formatting fixes * fixup! fixup! Baseline formatting fixes * Fix rust comment formatting * cxx_options.copy_from_rust: Avoid "mutable reference to mutable static" warning
1 parent fc01fa0 commit 9e2a594

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

docs/CHANGES.TXT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- Improvement: Ignore MXF Caption Essence Container version byte to enhance SRT subtitle extraction compatibility
3838
- New: Add tesseract page segmentation modes control with `--psm` flag
3939
- Fix: Resolve compile-time error about implicit declarations (#1646)
40+
- Fix: fatal out of memory error extracting from a VOB PS
4041

4142
0.94 (2021-12-14)
4243
-----------------

src/lib_ccx/dvd_subtitle_decoder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ int process_spu(struct lib_cc_decode *dec_ctx, unsigned char *buff, int length,
384384

385385
if (ctx->append == 1)
386386
{
387-
memcpy(ctx->buffer + ctx->len, buff, length);
387+
memmove(ctx->buffer + ctx->len, buff, length);
388388
ctx->len += length;
389389
ctx->append = 0;
390390
}

src/lib_ccx/ocr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ char *ocr_bitmap(void *arg, png_color *palette, png_byte *alpha, unsigned char *
620620
// realloc if memory allocated may be not enough
621621
int length_needed = (new_text_out_iter - new_text_out) +
622622
(line_end - line_start) +
623+
(last_font_tag_end ? (last_font_tag_end - last_font_tag) : 0) +
623624
length_closing_font + 32;
624625

625626
if (length_needed > length)

0 commit comments

Comments
 (0)