]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
malloc: Resolve compilation failure in NDEBUG mode
authorFlorian Weimer <fweimer@redhat.com>
Thu, 31 Aug 2017 12:55:11 +0000 (14:55 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 31 Aug 2017 13:34:22 +0000 (15:34 +0200)
In _int_free, the locked variable is not used if NDEBUG is defined.

ChangeLog
malloc/malloc.c

index ce8cb736fcdc7b0ea17ba3ef792d2f0d49aa0b85..79953a7d07e06aefa70c5f44671f5945463f1540 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-08-31  Florian Weimer  <fweimer@redhat.com>
+
+       * malloc/malloc.c (_int_free): Remove locked variable and related
+       asserts.
+
 2017-08-31  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #22051]
index 768670ccf6a48cf260e72db73aef7de4e4b46878..e1159a5bceba30df1c0eb8f6f971946f9edbeb81 100644 (file)
@@ -4106,8 +4106,6 @@ _int_free (mstate av, mchunkptr p, int have_lock)
   mchunkptr bck;               /* misc temp for linking */
   mchunkptr fwd;               /* misc temp for linking */
 
-  int locked = 0;
-
   size = chunksize (p);
 
   /* Little security check which won't hurt performance: the
@@ -4162,19 +4160,14 @@ _int_free (mstate av, mchunkptr p, int have_lock)
        /* We might not have a lock at this point and concurrent modifications
           of system_mem might have let to a false positive.  Redo the test
           after getting the lock.  */
-       if (have_lock
-           || ({ assert (locked == 0);
-                 __libc_lock_lock (av->mutex);
-                 locked = 1;
+       if (!have_lock
+           || ({ __libc_lock_lock (av->mutex);
                  chunksize_nomask (chunk_at_offset (p, size)) <= 2 * SIZE_SZ
-                   || chunksize (chunk_at_offset (p, size)) >= av->system_mem;
-             }))
+                 || chunksize (chunk_at_offset (p, size)) >= av->system_mem;
+               }))
          malloc_printerr ("free(): invalid next size (fast)");
        if (! have_lock)
-         {
-           __libc_lock_unlock (av->mutex);
-           locked = 0;
-         }
+         __libc_lock_unlock (av->mutex);
       }
 
     free_perturb (chunk2mem(p), size - 2 * SIZE_SZ);
@@ -4211,10 +4204,8 @@ _int_free (mstate av, mchunkptr p, int have_lock)
   */
 
   else if (!chunk_is_mmapped(p)) {
-    if (! have_lock) {
+    if (!have_lock)
       __libc_lock_lock (av->mutex);
-      locked = 1;
-    }
 
     nextchunk = chunk_at_offset(p, size);
 
@@ -4328,10 +4319,8 @@ _int_free (mstate av, mchunkptr p, int have_lock)
       }
     }
 
-    if (! have_lock) {
-      assert (locked);
+    if (!have_lock)
       __libc_lock_unlock (av->mutex);
-    }
   }
   /*
     If the chunk was allocated via mmap, release via munmap().