This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[3/8] Fix premature post-increment in collect2.c


A misplaced post-increment in collect2.c:ignore_library causes us to
skip the first element of aix_std_libs and dereference the null
terminator instead.

Tested on powerpc-ibm-aix6.1 and x86_64-linux-gnu.  OK to install?

Richard


gcc/
	* collect2.c (ignore_library): Avoid premature post-increment
	and null deference.

Index: gcc/collect2.c
===================================================================
--- gcc/collect2.c	2009-06-02 13:05:46.000000000 +0100
+++ gcc/collect2.c	2009-06-02 13:06:04.000000000 +0100
@@ -2444,8 +2444,9 @@ static int ignore_library (const char *)
 ignore_library (const char *name)
 {
   const char *const *p = &aix_std_libs[0];
-  while (*p++ != NULL)
-    if (! strcmp (name, *p)) return 1;
+  while (*p)
+    if (! strcmp (name, *p++))
+      return 1;
   return 0;
 }
 #endif /* COLLECT_EXPORT_LIST */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]