From: Ben Pfaff Date: Thu, 11 Feb 2010 04:08:28 +0000 (-0800) Subject: gui: Fix null pointer dereference in get_object_assert(). X-Git-Tag: v0.7.5~145 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52c0bf3d116ca8bc1d0b77b51dbe253ce9b32688;p=pspp-builds.git gui: Fix null pointer dereference in get_object_assert(). This function was checking whether o == NULL and then blindly dereferencing it after it found it to be so. Found by Clang (http://clang-analyzer.llvm.org). --- diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index 377f17a7..44396663 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007, 2009 Free Software Foundation + Copyright (C) 2007, 2009, 2010 Free Software Foundation This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -131,8 +131,7 @@ get_object_assert (GtkBuilder *builder, const gchar *name, GType type) if ( !o ) g_critical ("Object \"%s\" could not be found\n", name); - - if ( ! g_type_is_a (G_OBJECT_TYPE (o), type)) + else if ( ! g_type_is_a (G_OBJECT_TYPE (o), type)) { g_critical ("Object \"%s\" was expected to have type %s, but in fact has type %s", name, g_type_name (type), G_OBJECT_TYPE_NAME (o));