Check if deriv->steps is NULL before freeing it

This commit is contained in:
H.J. Lu 2012-09-07 14:14:08 -07:00
parent 5ca78dd024
commit de2139a9f2
2 changed files with 9 additions and 3 deletions

View File

@ -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 ...

View File

@ -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);
}