If you don't yet assume enough of post-K&R C (i.e., that
statement-after-declaration is ok), you'll want to move the declaration "up".

>From 8351f3220ce632a279c160c734d1bd3ac95de0fd Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Thu, 19 Mar 2009 14:53:59 +0100
Subject: [PATCH] don't store (and later dereference NULL) upon strdup failure

(ldso_path_build): Don't store NULL when strdup fails.
---
 lcr/lcr_ifact.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lcr/lcr_ifact.c b/lcr/lcr_ifact.c
index 4548b96..38647e9 100644
--- a/lcr/lcr_ifact.c
+++ b/lcr/lcr_ifact.c
@@ -263,7 +263,9 @@ static int ldso_path_build (const char *path, const char 
*filename)
                        ldso_path_build (newpath, new_filename);
                        continue;
                }
-               path_list[path_list_entries++] = strdup (string);
+               char *p = strdup (string);
+               if (p)
+                       path_list[path_list_entries++] = p;
        }
        fclose(fp);
 #endif
--
1.6.2.rc1.285.gc5f54
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to