From patchwork Fri Oct 16 14:40:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23020 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 B0BC044A470 for ; Fri, 16 Oct 2020 17:41:44 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 860F468BA8A; Fri, 16 Oct 2020 17:41:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F150568BA62 for ; Fri, 16 Oct 2020 17:41:37 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id n15so3237343wrq.2 for ; Fri, 16 Oct 2020 07:41:37 -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:mime-version :content-transfer-encoding; bh=y5H+eY04WwQiX8ypXZsy+PUPwZBT4kYPA8f1cgtfB34=; b=tJFWnM4kZXXk0TsANFJzEokgWHLQp2SSgIQ7s6z9Y4v0hG+MruAnRYn0Vl0wuUIfB+ Jehj+R+GwfdYXgyrm+uBUuM5pnRH7gxZPV2km1ie77xEzlL5W0ls8Khj0fepu9gHAUxS mALUJJ4+44I3m3fRJhcsrMU9amqB/WFUY0kIZwuvxb2uwHf8pBEKbTvirGRjevqaoJZl S8Ix90eSJo7615sEEp9hczC5cUCRt9mdDg0jVkoEAfPwNnPYpb3UqO/+S+6YLRpIKFK3 /m4FAWqXryPFRL4PXmCwdLYYeJLqyzaEuwSbKqSNY4XPPGHpy0BP9b555CLQRMIAZ1M2 lDuw== 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:mime-version :content-transfer-encoding; bh=y5H+eY04WwQiX8ypXZsy+PUPwZBT4kYPA8f1cgtfB34=; b=EWA/QBP8NIQ8/7lq3WlBpqL5wO/CwR8Io/iHKKFNZVWbZTEDsJePFXtUa9+XqTT7lT QvdkBg3yfZsx2rvPLDgxd9Uz9IH3Dv1Ryb7Al6kH3heEOJjMu0GKXe9tuoDYMlvUz6LS svprDOCjbOF/G4PSADLDqtoGJYTdBdz8c2U/kH6jB4J0gIKOSBOYFijtPRTNwfYLrX3t K3ZOdliZzHmIEMzD93f3WPFgyRI6UkOrvUbyXFnSCErnsyL6vKCHRpEL59qtmNz4huMK I7AlSeq3pId8g0nUkXVKMik12JdAfxNsxiphmHQZgB+ZkUxzMZRP4MQVBzKh2APO/VVm WZZg== X-Gm-Message-State: AOAM530XLeEoKgM3WYPaJsIOjHmrkAuid85Zf/leDuDLAQpB9TD3Zi8t VZ5NlE/UmhiEGkB/UD6wHTMNBxz5WnY= X-Google-Smtp-Source: ABdhPJzro6m2OahFnMC6JLBcgOhgtYu4bAifst6JZDrVWuLnIYVNnd1+oF69bPJ+5sJnIFpA7yKe5A== X-Received: by 2002:adf:f44d:: with SMTP id f13mr4153530wrp.385.1602859297060; Fri, 16 Oct 2020 07:41:37 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2020 07:41:36 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Oct 2020 16:40:34 +0200 Message-Id: <20201016144035.308668-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/movtextdec: Reset array counter after freeing array 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" Otherwise the mov_text muxer can segfault when given subtitles with more than one AVSubtitleRect if one of the first nb_rects - 1 rects contained a style attribute. Signed-off-by: Andreas Rheinhardt --- I wonder whether we should also reset the STYL_BOX flag of s->box_flags. libavcodec/movtextenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 67d29a09ca..3cf308aac8 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -102,6 +102,7 @@ static void mov_text_cleanup(MovTextContext *s) av_freep(&s->style_attributes[j]); } av_freep(&s->style_attributes); + s->count = 0; } if (s->style_attributes_temp) { *s->style_attributes_temp = s->d; 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;