Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/tre/dist/lib Fix allocation size with wrong use...



details:   https://anonhg.NetBSD.org/src/rev/c1392b36bfa6
branches:  trunk
changeset: 357636:c1392b36bfa6
user:      rin <rin%NetBSD.org@localhost>
date:      Sun Nov 19 12:13:14 2017 +0000

description:
Fix allocation size with wrong use of sizeof, taken from musl libc:
https://git.musl-libc.org/cgit/musl/commit/src/regex/regcomp.c?id=1e81fa4524ecfd51e6a6578ff8038b4c05393101

diffstat:

 external/bsd/tre/dist/lib/tre-compile.c |  2 +-
 external/bsd/tre/dist/lib/tre-parse.c   |  6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diffs (42 lines):

diff -r e0cd3e4d5d6c -r c1392b36bfa6 external/bsd/tre/dist/lib/tre-compile.c
--- a/external/bsd/tre/dist/lib/tre-compile.c   Sun Nov 19 07:41:52 2017 +0000
+++ b/external/bsd/tre/dist/lib/tre-compile.c   Sun Nov 19 12:13:14 2017 +0000
@@ -1949,7 +1949,7 @@
                 sizeof(*tag_directions) * (tnfa->num_tags + 1));
        }
       tnfa->minimal_tags = xcalloc((unsigned)tnfa->num_tags * 2 + 1,
-                                  sizeof(tnfa->minimal_tags));
+                                  sizeof(*tnfa->minimal_tags));
       if (tnfa->minimal_tags == NULL)
        ERROR_EXIT(REG_ESPACE);
 
diff -r e0cd3e4d5d6c -r c1392b36bfa6 external/bsd/tre/dist/lib/tre-parse.c
--- a/external/bsd/tre/dist/lib/tre-parse.c     Sun Nov 19 07:41:52 2017 +0000
+++ b/external/bsd/tre/dist/lib/tre-parse.c     Sun Nov 19 12:13:14 2017 +0000
@@ -108,7 +108,7 @@
       if (*max_i > 1024)
        return REG_ESPACE;
       *max_i *= 2;
-      new_items = xrealloc(array, sizeof(*items) * *max_i);
+      new_items = xrealloc(array, sizeof(*array) * *max_i);
       if (new_items == NULL)
        return REG_ESPACE;
       *items = array = new_items;
@@ -509,7 +509,7 @@
          if (num_neg_classes > 0)
            {
              l->neg_classes = tre_mem_alloc(ctx->mem,
-                                            (sizeof(l->neg_classes)
+                                            (sizeof(*l->neg_classes)
                                              * (num_neg_classes + 1)));
              if (l->neg_classes == NULL)
                {
@@ -550,7 +550,7 @@
          if (num_neg_classes > 0)
            {
              l->neg_classes = tre_mem_alloc(ctx->mem,
-                                            (sizeof(l->neg_classes)
+                                            (sizeof(*l->neg_classes)
                                              * (num_neg_classes + 1)));
              if (l->neg_classes == NULL)
                {



Home | Main Index | Thread Index | Old Index