Code was allocating way too much space for the string.

gcc/ChangeLog:
        * config/bpf/core-builtins.cc (process_enum_value): Corrected
        string allocation.
---
 gcc/config/bpf/core-builtins.cc | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/config/bpf/core-builtins.cc b/gcc/config/bpf/core-builtins.cc
index e03e986e2c1..ead1777d465 100644
--- a/gcc/config/bpf/core-builtins.cc
+++ b/gcc/config/bpf/core-builtins.cc
@@ -872,10 +872,11 @@ process_enum_value (struct cr_builtins *data)
        {
          if (TREE_VALUE (l) == expr)
            {
-             char *tmp = (char *) ggc_alloc_atomic ((index / 10) + 1);
+             /* Array size is 21 = ceil(log_10(2^64)) + 1 to hold string
+                representations of 64 bit integers.  */
+             char tmp[21];
              sprintf (tmp, "%d", index);
-             ret.str = (const char *) tmp;
-
+             ret.str = CONST_CAST (char *, ggc_strdup(tmp));
              break;
            }
          index++;
-- 
2.30.2

Reply via email to