]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
2005-01-25 Jakub Jelinek <jakub@redhat.com>
authorRoland McGrath <roland@gnu.org>
Wed, 16 Feb 2005 10:37:10 +0000 (10:37 +0000)
committerRoland McGrath <roland@gnu.org>
Wed, 16 Feb 2005 10:37:10 +0000 (10:37 +0000)
[BZ #731]
* stdlib/fmtmsg.c (addseverity): Remove new_string variable.
(free_mem): Don't free string.
* stdlib/tst-fmtmsg.c: Include string.h.
(main): Add some more tests.
2005-01-14  Ulrich Drepper  <drepper@redhat.com>

[BZ #731]
* stdlib/fmtmsg.c (internal_addseverity): Remove incorrect free call.
* stdlib/tst-fmtmsg.c (main): Add another addseverity test.

stdlib/fmtmsg.c

index 2ab97b7d9033945a36b6d09da041d56cf73f39a4..7505e4c78dd00e7700f1e7f405e09785994acce9 100644 (file)
@@ -316,7 +316,7 @@ internal_addseverity (int severity, const char *string)
   int result = MM_OK;
 
   /* First see if there is already a record for the severity level.  */
-  for (runp = severity_list, lastp = NULL; runp != NULL; runp = runp-> next)
+  for (runp = severity_list, lastp = NULL; runp != NULL; runp = runp->next)
     if (runp->severity == severity)
       break;
     else
@@ -324,9 +324,6 @@ internal_addseverity (int severity, const char *string)
 
   if (runp != NULL)
     {
-      /* Release old string.  */
-      free ((char *) runp->string);
-
       if (string != NULL)
        /* Change the string.  */
        runp->string = string;
@@ -367,34 +364,17 @@ int
 addseverity (int severity, const char *string)
 {
   int result;
-  const char *new_string;
 
   /* Prevent illegal SEVERITY values.  */
   if (severity <= MM_INFO)
     return MM_NOTOK;
 
-  if (string == NULL)
-    /* We want to remove the severity class.  */
-    new_string = NULL;
-  else
-    {
-      new_string = __strdup (string);
-
-      if (new_string == NULL)
-       /* Allocation failed or illegal value.  */
-       return MM_NOTOK;
-    }
-
   /* Protect the global data.  */
   __libc_lock_lock (lock);
 
   /* Do the real work.  */
   result = internal_addseverity (severity, string);
 
-  if (result != MM_OK)
-    /* Free the allocated string.  */
-    free ((char *) new_string);
-
   /* Release the lock.  */
   __libc_lock_unlock (lock);
 
@@ -411,7 +391,6 @@ libc_freeres_fn (free_mem)
       {
        /* This is data we have to release.  */
        struct severity_info *here = runp;
-       free ((char *) runp->string);
        runp = runp->next;
        free (here);
       }