This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Re: [PATCH] Check if deriv->steps is NULL before freeing it


On Fri, Sep 7, 2012 at 1:29 PM, Roland McGrath <roland@hack.frob.com> wrote:
> Don't use implicit boolean coercion.

This is what I checked in.

-- 
H.J.
----
diff --git a/ChangeLog b/ChangeLog
index 6d3823e..77ae95c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2012-09-07  H.J. Lu  <hongjiu.lu@intel.com>

+	* iconv/gconv_db.c (free_derivation): Check if deriv->steps
+	is NULL.
+
 	* debug/Makefile (LDFLAGS-tst-chk4): Renamed to ...
 	(LDLIBS-tst-chk4): This.
 	(LDFLAGS-tst-chk5): Renamed to ...
diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c
index a081205..5bc7ff8 100644
--- a/iconv/gconv_db.c
+++ b/iconv/gconv_db.c
@@ -193,10 +193,13 @@ free_derivation (void *p)
       }

   /* Free the name strings.  */
-  free ((char *) deriv->steps[0].__from_name);
-  free ((char *) deriv->steps[deriv->nsteps - 1].__to_name);
+  if (deriv->steps != NULL)
+    {
+      free ((char *) deriv->steps[0].__from_name);
+      free ((char *) deriv->steps[deriv->nsteps - 1].__to_name);
+      free ((struct __gconv_step *) deriv->steps);
+    }

-  free ((struct __gconv_step *) deriv->steps);
   free (deriv);
 }


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