From patchwork Fri Oct 16 14:40:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23021 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id E437B44A470 for ; Fri, 16 Oct 2020 17:42:01 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CB60068BACB; Fri, 16 Oct 2020 17:42:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9DAD168BAC7 for ; Fri, 16 Oct 2020 17:41:55 +0300 (EEST) Received: by mail-wm1-f68.google.com with SMTP id d81so2732375wmc.1 for ; Fri, 16 Oct 2020 07:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4tJw9wsDDZt1EcBOY9pbgHBJ1p89JJR6Grv+CcGaook=; b=jiDDnOClXQRx6QMnbS/+wntwqonuKaB03o/y3q7S88uzvMMRQNaIVpBZzYmFLDhmHt ZjfktdIt8LnErHkwwQg/gGqd5pR9TAa8d9xoaUskQLw1yhBR5+ivZ+7opgEBnBWgA6b8 oM9fOBouQxVxvakpPFubPYxrSs9u84d5ticup+FxKlb7WuiMeCiCSziTmlxIb0hqLOE7 1v5mTh1rWav2j2BW3PLT5RAEQdo8YC0OayaWgCk/st0iiYxGVtQ0oYaK/WU/ktu7WEhF G2EkbigVYed2q9SnMOdcvzPQlnjWkVwhlaBRekz0EQ3hYLylRta5s2gO7NmNeB/myN8X fPkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4tJw9wsDDZt1EcBOY9pbgHBJ1p89JJR6Grv+CcGaook=; b=ixiF9d+HEmm/tmQAZZjhwPDLkVonz/DC8vSWV+OFgZQDYCkIasZvEiyZ55ci8BI9jx XJnBtrdQ/FTNQP++2fgvFdbVT4JCROn+MGiOjKF4WHW+gtH1Cd2LWUsF1l95cMQcRRAn FVX4P3dcqDgsZRxmfdPuNGKyJl9eijTJwIT8aDqbCg0V1Va+AGYcxGfecNqrjIRDKb9i IGi/vCvCOA4vFmJT3oGHvv37InvKmZaFFAjHhXDKwqJ2Zzu45GxIr4xNe7mUOoYkAFny uvdhTm4biw7gRW6vUC0UKkAOg35zPfwpwn3wedmYbn4BHizrNMa9SAFZvt7PG7ro679B BZyQ== X-Gm-Message-State: AOAM532hVxhLsVc4rMqLhdynGuWhoL7AQfh6Y9xd7YWLpWTcrybk2lnU 0gGJ7+KQLsIZD430FI3P86VDIHIE0/w= X-Google-Smtp-Source: ABdhPJx0zsKCpC2iYBlLDdFp/VqhVt9VzY611mn8ecDyrWsBC8wEpzOY2fCPOEwIWaj69qHEiIvbtA== X-Received: by 2002:a7b:c1c2:: with SMTP id a2mr4065954wmj.23.1602859314772; Fri, 16 Oct 2020 07:41:54 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id x64sm3025503wmg.33.2020.10.16.07.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2020 07:41:54 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Oct 2020 16:40:35 +0200 Message-Id: <20201016144035.308668-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201016144035.308668-1-andreas.rheinhardt@gmail.com> References: <20201016144035.308668-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/movtextenc: Don't presume every style to have a font X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes segfaults in the absence of fonts; this can happen because the file didn't contain any or because the allocation of the font-string failed. Signed-off-by: Andreas Rheinhardt --- Do ASS files actually have to prescribe the font? libavcodec/movtextenc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 3cf308aac8..dc2715951f 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -279,10 +279,14 @@ static int encode_sample_description(AVCodecContext *avctx) // is avaiable in the ASS header if (style && ass->styles_count) { // Find unique font names - av_dynarray_add(&s->fonts, &s->font_count, style->font_name); - font_names_total_len += strlen(style->font_name); + if (style->font_name) { + av_dynarray_add(&s->fonts, &s->font_count, style->font_name); + font_names_total_len += strlen(style->font_name); + } for (i = 0; i < ass->styles_count; i++) { int found = 0; + if (!ass->styles[i].font_name) + continue; for (j = 0; j < s->font_count; j++) { if (!strcmp(s->fonts[j], ass->styles[i].font_name)) { found = 1;