mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-15 13:35:30 +00:00
Fix segfault in add_cc_sub_text and initialize to NULL in init_encoder (#950)
This commit adds some checks to avoid segmentation faults. * In `add_cc_sub_text()`, strdup will cause a segfault if we duplicate an empty string. * In `init_encoder()`, initialize pointer fields to NULL to avoid random addressing so we can avoid illegal memory accessing and segfaults in other places.
This commit is contained in:
committed by
Carlos Fernandez Sanz
parent
a0e7ddd632
commit
f46e3dcfc2
@@ -70,6 +70,8 @@ void freep(void *arg)
|
||||
int add_cc_sub_text(struct cc_subtitle *sub, char *str, LLONG start_time,
|
||||
LLONG end_time, char *info, char *mode, enum ccx_encoding_type e_type)
|
||||
{
|
||||
if (str == NULL || strlen(str) == 0)
|
||||
return 0;
|
||||
if (sub->nb_data)
|
||||
{
|
||||
for(;sub->next;sub = sub->next);
|
||||
|
||||
@@ -1038,6 +1038,7 @@ struct encoder_ctx *init_encoder(struct encoder_cfg *opt)
|
||||
ctx->segment_last_key_frame = 0;
|
||||
ctx->nospupngocr = opt->nospupngocr;
|
||||
|
||||
ctx->prev = NULL;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user