GNOME Bugzilla – Bug 751823
glimagesink: possible null pointer dereference
Last modified: 2015-08-16 13:41:33 UTC
during context_error, while trying to print the error message,
there is no check if error is allocated. Ideally error will be allocated
and we need not have a check at all. But just in case
Created attachment 306588 [details] [review]
prevent possible null pointer dereference
I see where you're coming from here (I'm guessing some static analyzer complained that you're dereferencing error unconditionally and later check if it's non-NULL), but I don't think this should be fixed like that.
If a function returns a GError on failure, it should always do that. And _create_context() always does that as far as I can tell. So the right thing to do would be to drop the if (error) check here, or to use g_clear_error() instead (which may or may not make the static analyzer shut up).
Created attachment 306590 [details] [review]
g_clear_error does the trick of shutting up static analysis tool :)
Thanks Vineeth, and good explanation in the commit message.
"replace g_error_free with g_clear_error, as it internally checks if error variable is valid or not."
Review of attachment 306590 [details] [review]:
Author: Vineeth TM <email@example.com>
Date: Thu Jul 2 17:08:26 2015 +0900
glimagesink: use g_clear_error instead of g_error_free
replace g_error_free with g_clear_error, as it internally
checks if error variable is valid or not.