From patchwork Tue May 15 18:58:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 913870 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40ln0K3gMzz9s01 for ; Wed, 16 May 2018 04:58:41 +1000 (AEST) Received: from localhost ([::1]:54648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIf9j-0001mV-6s for incoming@patchwork.ozlabs.org; Tue, 15 May 2018 14:58:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIf9O-0001ll-E7 for qemu-devel@nongnu.org; Tue, 15 May 2018 14:58:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIf9N-0005ED-LL for qemu-devel@nongnu.org; Tue, 15 May 2018 14:58:18 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:41740) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fIf9N-0005Du-Ek for qemu-devel@nongnu.org; Tue, 15 May 2018 14:58:17 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1fIf9L-0001kb-9T; Tue, 15 May 2018 19:58:15 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 15 May 2018 19:58:14 +0100 Message-Id: <20180515185814.1374-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH] sdl: Move use of surface pointer below check for whether it is NULL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anatoly Trosinenko , Gerd Hoffmann , patches@linaro.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" In commit 2ab858c6c38ee1 we added a use of the 'surf' variable in sdl2_2d_update() that was unfortunately placed above the early-exit-if-NULL check. Move it to where it ought to be. Fixes: Coverity CID 1390598 Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- ui/sdl2-2d.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/sdl2-2d.c b/ui/sdl2-2d.c index 1f34817bae..85484407be 100644 --- a/ui/sdl2-2d.c +++ b/ui/sdl2-2d.c @@ -36,9 +36,7 @@ void sdl2_2d_update(DisplayChangeListener *dcl, struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); DisplaySurface *surf = qemu_console_surface(dcl->con); SDL_Rect rect; - size_t surface_data_offset = surface_bytes_per_pixel(surf) * x + - surface_stride(surf) * y; - + size_t surface_data_offset; assert(!scon->opengl); if (!surf) { @@ -48,6 +46,8 @@ void sdl2_2d_update(DisplayChangeListener *dcl, return; } + surface_data_offset = surface_bytes_per_pixel(surf) * x + + surface_stride(surf) * y; rect.x = x; rect.y = y; rect.w = w;