File: malloca.c.diff

package info (click to toggle)
libidn 1.43-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,376 kB
  • sloc: java: 14,167; ansic: 7,085; cs: 1,974; sh: 1,283; perl: 1,238; makefile: 680; lisp: 231; php: 214; xml: 88; python: 9
file content (47 lines) | stat: -rw-r--r-- 2,024 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
diff --git a/lib/malloca.c b/lib/malloca.c
index e75c72df84..6938cdce7a 100644
--- a/lib/malloca.c
+++ b/lib/malloca.c
@@ -69,25 +69,27 @@ mmalloca (size_t n)
              theoretical platforms where UINTPTR_MAX <= INT_MAX.  */
           uintptr_t umemplus;
           ckd_add (&umemplus, umem, sizeof (small_t) + sa_alignment_max - 1);
-          idx_t offset = (umemplus - umemplus % (2 * sa_alignment_max)
-                          + sa_alignment_max - umem);
-          void *p = mem + offset;
-          /* Here p >= mem + sizeof (small_t),
-             and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1
-             hence p + n <= mem + nplus.
-             So, the memory range [p, p+n) lies in the allocated memory range
-             [mem, mem + nplus).  */
-          small_t *sp = p;
+          {
+            idx_t offset = (umemplus - umemplus % (2 * sa_alignment_max)
+                            + sa_alignment_max - umem);
+            void *p = mem + offset;
+            /* Here p >= mem + sizeof (small_t),
+               and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1
+               hence p + n <= mem + nplus.
+               So, the memory range [p, p+n) lies in the allocated memory range
+               [mem, mem + nplus).  */
+            small_t *sp = p;
 # if defined __CHERI_PURE_CAPABILITY__
-          sp[-1] = umem;
-          p = (char *) cheri_bounds_set ((char *) p - sizeof (small_t),
-                                         sizeof (small_t) + n)
+            sp[-1] = umem;
+            p = (char *) cheri_bounds_set ((char *) p - sizeof (small_t),
+                                           sizeof (small_t) + n)
               + sizeof (small_t);
 # else
-          sp[-1] = offset;
+            sp[-1] = offset;
 # endif
-          /* p ≡ sa_alignment_max mod 2*sa_alignment_max.  */
-          return p;
+            /* p ≡ sa_alignment_max mod 2*sa_alignment_max.  */
+            return p;
+          }
         }
     }
   /* Out of memory.  */