From patchwork Tue Apr 10 13:03:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Oliver X-Patchwork-Id: 8375 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp1038224jad; Tue, 10 Apr 2018 06:10:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4915hO/7I4aCmfazSpt7UR06afAqngLsSnPZRPi2Vyh+oBC558XOYE6FRAFiA6KGXZ7PeMS X-Received: by 10.223.209.72 with SMTP id b8mr300261wri.122.1523365858722; Tue, 10 Apr 2018 06:10:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523365858; cv=none; d=google.com; s=arc-20160816; b=sdqY1JwLhNP+RkBhMkEHiMvj2doEfnnT6cRzxcyukuBqyChRI97Ev4jmi8GG/Wk9+n j0ycZMztzmNaJ8jp+7g5Aa1ElKCD4i1m7TM4nXvq7yfIUUliiXuqCJe+cX/zTY2/25yL rdZktNivD+V1N99eCSDhV8ZGGVe4yJU/hyolwZONDxxtTEihq+Z9y+9o5UkYp1LZQ0Ho um1miSwO0yfVR0Nzr1RZngkjSQxR1z9bbzSg/YJwgrKlsf9b+usLzjw0m2g63dPPCkM2 Y3Y5ZZrvenZGmucjeTh3PxCWd8Bez+RpTvel30kt6b7C4UzqiX+GgviDKReYi6ax1d8g vtxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to :arc-authentication-results; bh=kUgy5WWsqy/UvrYF6kmUjuT3PfKScMXzNVn/CUcZyM0=; b=RFkrNwMZEULNnstHC1lm5xMQfPZqCEmmYdHaqSSaOXJS2Gz3Rv7C2x8IobQr71sTmd ZlpxQFxVQlJ9r25K7Go0pGOv597tPXXdUJ8ZK8RHmrCIpDg+WzfWzJQ4tfijGXweHUKX iKiF1+3XmY51yVX07kQQDpP9M9BoIfZ5vWgsNAZWiv7NWoCpXTko8bT2ZpCrAcD4QtF/ U5EWphCvADTiC7rOR1DCgOGaOdZ/QiWFIgK94jFpRs4dllcHkAmLfPG4TCIYmHMVf5PX 8v7QwoqHvJn58ZYWwgOVg3a4JQLUDrH6i0fpGPQbXdrVK7oYP2qW1r9NNX+jKVZFyzF6 UPsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ERWueKth; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s4si1816926wrg.348.2018.04.10.06.10.57; Tue, 10 Apr 2018 06:10:58 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ERWueKth; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2AA54689F52; Tue, 10 Apr 2018 16:10:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi0-f65.google.com (mail-oi0-f65.google.com [209.85.218.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E11CD689EC7 for ; Tue, 10 Apr 2018 16:10:24 +0300 (EEST) Received: by mail-oi0-f65.google.com with SMTP id l190-v6so11052339oig.9 for ; Tue, 10 Apr 2018 06:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=zBwBkzkKdTglRgW2CqgIswAIpmUkDCyrB269fdlkyVk=; b=ERWueKthYQocM6IsO/YQW6+/Dh+wO9WfeGU3PYpyjE8PJPHukuN69S175dupCd7y76 WSSZIYQykDpR1XkjLEY2sY+/Y+ojmZp/Aop8ij+ks0GuQXLHLjgYWK/HzcxFa6jDCphP kmdvu70fGQkbcXoUZ+Lz0ahgSUtGQ8BpL7aC9u4iBL7T5M/RFtoqLaQPwD4pSphvo8vn YWRGHDH9Pck/3DDnedNMYDZrRQ56SuBAL5WoUHslKlRHWxg8sgd4PDzVb7A30e15EOAR leaL495PLKmL5DvanvvpRBUxscHiNwmrKA4kvj+UQ9z860/y9d9QHYmFU1E1gXx4/BnB JjpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=zBwBkzkKdTglRgW2CqgIswAIpmUkDCyrB269fdlkyVk=; b=jHQxtuTpAKmfAg4/LtlC5JYGgV29bw28zYi3dKcODXAZpWRqcpdUYZxkuvVti3YJ8V 1yndkttiiaFWJ6EgW71kQDcAY3dM4QtAr2BOIpSaJ082Mc+w7z1GYGEhDjbX0dCncdmC DnBIzViUkOJJ8X4o3tg23ZWdNVq9YrkTi4G9hVO5NUjnZYNhaWVm0/1LGPxpYmHGqOqq NQ788LaRcFYmKs/QKHZjv9x4C8NH2bbsyG0HkqJynhA+j7I8mcUiptZAlNHEbOqYFdpS P8l/7BP39ofFgwxywmvD9MZgSX3n9OX76GXKTnbyoNJBhkvU4OPz2rytPyJMmaxuQ1MA dR8Q== X-Gm-Message-State: ALQs6tAo819czLUza0DPLQzTse9RKokK7lhnppvWwOCKVh5dYSHbgIPr MAeojHgjzQqFAJ/4ZOa1r03jCBHkVTmtYgXwWAWltY/9 X-Received: by 2002:aca:600a:: with SMTP id u10-v6mr218186oib.96.1523365437065; Tue, 10 Apr 2018 06:03:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.201.20.99 with HTTP; Tue, 10 Apr 2018 06:03:56 -0700 (PDT) From: Matt Oliver Date: Tue, 10 Apr 2018 23:03:56 +1000 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] ffplay: Fix realloc_texture when input texture is NULL. 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" SDL_QueryTexture and SDL_DestroyTexture require that the input texture pointer be non-null. Debug builds of SDL will correctly check for this and break program execution. This patch fixes this by checking the status of the texture pointer. Signed-off-by: Matt Oliver --- fftools/ffplay.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) if (!(*texture = SDL_CreateTexture(renderer, new_format, SDL_TEXTUREACCESS_STREAMING, new_width, new_height))) return -1; if (SDL_SetTextureBlendMode(*texture, blendmode) < 0) -- diff --git a/fftools/ffplay.c b/fftools/ffplay.c index bc9ddb8885..dcca9c26d8 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -834,10 +834,11 @@ static int realloc_texture(SDL_Texture **texture, Uint32 new_format, int new_wid { Uint32 format; int access, w, h; - if (SDL_QueryTexture(*texture, &format, &access, &w, &h) < 0 || new_width != w || new_height != h || new_format != format) { + if (!*texture || SDL_QueryTexture(*texture, &format, &access, &w, &h) < 0 || new_width != w || new_height != h || new_format != format) { void *pixels; int pitch; - SDL_DestroyTexture(*texture); + if (*texture) + SDL_DestroyTexture(*texture);