[geany/geany] f23b72: Fix possible dereference of NULL pointer
Colomban Wendling
git-noreply at xxxxx
Sat Jul 13 20:13:07 UTC 2013
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Sat, 13 Jul 2013 20:13:07 UTC
Commit: f23b7267cffcb615a4f970d824b38c04d58fc426
https://github.com/geany/geany/commit/f23b7267cffcb615a4f970d824b38c04d58fc426
Log Message:
-----------
Fix possible dereference of NULL pointer
Use g_set_error() instead of doing it manually and forgetting to check
whether the pointer is NULL or not before dereferencing it.
Spotted by clang --analyze.
Modified Paths:
--------------
src/utils.c
Modified: src/utils.c
27 files changed, 2 insertions(+), 25 deletions(-)
===================================================================
@@ -1657,23 +1657,6 @@ const gchar *utils_get_default_dir_utf8(void)
}
-static gboolean check_error(GError **error)
-{
- if (error != NULL && *error != NULL)
- {
- /* imitate the GLib warning */
- g_warning(
- "GError set over the top of a previous GError or uninitialized memory.\n"
- "This indicates a bug in someone's code. You must ensure an error is NULL "
- "before it's set.");
- /* after returning the code may segfault, but we don't care because we should
- * make sure *error is NULL */
- return FALSE;
- }
- return TRUE;
-}
-
-
/**
* Wraps g_spawn_sync() and internally calls this function on Unix-like
* systems. On Win32 platforms, it uses the Windows API.
@@ -1697,12 +1680,9 @@ gboolean utils_spawn_sync(const gchar *dir, gchar **argv, gchar **env, GSpawnFla
{
gboolean result;
- if (! check_error(error))
- return FALSE;
-
if (argv == NULL)
{
- *error = g_error_new(G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED, "argv must not be NULL");
+ g_set_error(error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED, "argv must not be NULL");
return FALSE;
}
@@ -1743,12 +1723,9 @@ gboolean utils_spawn_async(const gchar *dir, gchar **argv, gchar **env, GSpawnFl
{
gboolean result;
- if (! check_error(error))
- return FALSE;
-
if (argv == NULL)
{
- *error = g_error_new(G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED, "argv must not be NULL");
+ g_set_error(error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED, "argv must not be NULL");
return FALSE;
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list