Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib_ccx/ccx_encoders_sami.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int write_stringz_as_sami(char *string, struct encoder_ctx *context, LLONG ms_st
// 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;
Expand All @@ -62,7 +62,7 @@ int write_stringz_as_sami(char *string, struct encoder_ctx *context, LLONG ms_st
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)
Expand Down
4 changes: 2 additions & 2 deletions src/lib_ccx/ccx_encoders_smptett.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void write_stringz_as_smptett(char *string, struct encoder_ctx *context, LLONG m
// 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;
Expand All @@ -76,7 +76,7 @@ void write_stringz_as_smptett(char *string, struct encoder_ctx *context, LLONG m
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)
Expand Down
4 changes: 2 additions & 2 deletions src/lib_ccx/ccx_encoders_webvtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ int write_stringz_as_webvtt(char *string, struct encoder_ctx *context, LLONG ms_
// 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;
Expand All @@ -170,7 +170,7 @@ int write_stringz_as_webvtt(char *string, struct encoder_ctx *context, LLONG ms_
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)
Expand Down
Loading