From 8d85b32c0fd319318a6b5c8f3106e121d0c9a4ea Mon Sep 17 00:00:00 2001 From: rhythmcache <153998419+rhythmcache@users.noreply.github.com> Date: Fri, 20 Feb 2026 08:28:13 +0530 Subject: [PATCH 1/2] Fix loop condition for reading unescaped string --- src/lib_ccx/ccx_encoders_srt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib_ccx/ccx_encoders_srt.c b/src/lib_ccx/ccx_encoders_srt.c index 865c6e229..efd3206f8 100644 --- a/src/lib_ccx/ccx_encoders_srt.c +++ b/src/lib_ccx/ccx_encoders_srt.c @@ -62,7 +62,7 @@ static int write_stringz_as_srt_to_output(char *string, struct encoder_ctx *cont unescaped[pos_w] = 0; // Now read the unescaped string (now several string'z and write them) unsigned char *begin = unescaped; - while (begin < unescaped + len) + while (begin < unescaped + pos_w) { unsigned int u = encode_line(context, el, begin); if (context->encoding != CCX_ENC_UNICODE) From adb2e709a4592a32ab4bc2b81632c7510f611819 Mon Sep 17 00:00:00 2001 From: rhythmcache <153998419+rhythmcache@users.noreply.github.com> Date: Fri, 20 Feb 2026 08:29:55 +0530 Subject: [PATCH 2/2] Fix condition to check for newline escape sequence --- src/lib_ccx/ccx_encoders_srt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib_ccx/ccx_encoders_srt.c b/src/lib_ccx/ccx_encoders_srt.c index efd3206f8..96753af57 100644 --- a/src/lib_ccx/ccx_encoders_srt.c +++ b/src/lib_ccx/ccx_encoders_srt.c @@ -47,7 +47,7 @@ static int write_stringz_as_srt_to_output(char *string, struct encoder_ctx *cont // Scan for \n in the string and replace it with a 0 while (pos_r < len) { - if (string[pos_r] == '\\' && string[pos_r + 1] == 'n') + if (pos_r < len - 1 && string[pos_r] == '\\' && string[pos_r + 1] == 'n') { unescaped[pos_w] = 0; pos_r += 2;