From: Christian Grothoff Date: Thu, 4 Mar 2010 09:22:01 +0000 (+0000) Subject: handle NULL return, fix leak X-Git-Tag: initial-import-from-subversion-38251~22573 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=228b8212acd8be04828d1b33bf07b6c839825b91;p=oweals%2Fgnunet.git handle NULL return, fix leak --- diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 93bfb8885..4895e758a 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c @@ -358,20 +358,16 @@ get_path_from_PATH () sprintf (buf, "%s/%s", pos, "gnunet-nat-server"); if (GNUNET_DISK_file_test (buf) == GNUNET_YES) { - pos = GNUNET_strdup (buf); - GNUNET_free (buf); GNUNET_free (path); - return pos; + return buf; } pos = end + 1; } sprintf (buf, "%s/%s", pos, "gnunet-nat-server"); if (GNUNET_DISK_file_test (buf) == GNUNET_YES) { - pos = GNUNET_strdup (buf); - GNUNET_free (buf); GNUNET_free (path); - return pos; + return buf; } GNUNET_free (buf); GNUNET_free (path); @@ -383,9 +379,17 @@ static int check_gnunet_nat_server() { struct stat statbuf; + char *p; - if (0 != STAT (get_path_from_PATH(), &statbuf)) - return GNUNET_SYSERR; + p = get_path_from_PATH (); + if (p == NULL) + return GNUNET_NO; + if (0 != STAT (p, &statbuf)) + { + GNUNET_free (p); + return GNUNET_SYSERR; + } + GNUNET_free (p); if ( (0 != (statbuf.st_mode & S_ISUID)) && (statbuf.st_uid == 0) ) return GNUNET_YES;