bug-gawk
[Top][All Lists]
Advanced

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

Re: Internal error with gawk-5.3.0


From: Miguel Pineiro Jr.
Subject: Re: Internal error with gawk-5.3.0
Date: Sun, 07 Jan 2024 19:27:52 -0500
User-agent: Cyrus-JMAP/3.9.0-alpha0-1364-ga51d5fd3b7-fm-20231219.001-ga51d5fd3

On Sun, Jan 7, 2024, at 2:34 PM, arnold@skeeve.com wrote:
> Hi.
>
> The attached patch seems to do the trick for me.
>
> Arnold

Alternatively, the allocation of the array can be done at the top. ezalloc 
leaves it properly initialized for the Nnull_string and Null_field cases. 

diff --git a/node.c b/node.c
index de12f05d..59c0b98e 100644
--- a/node.c
+++ b/node.c
@@ -815,6 +815,18 @@ str2wstr(NODE *n, size_t **ptr)
 
        assert((n->flags & (STRING|STRCUR)) != 0);
 
+       /*
+        * For use by do_match, create and fill in an array.
+        * For each byte `i' in n->stptr (the original string),
+        * a[i] is equal to `j', where `j' is the corresponding wchar_t
+        * in the converted wide string.
+        *
+        * Create the array.
+        */
+       if (ptr != NULL) {
+               ezalloc(*ptr, size_t *, sizeof(size_t) * (n->stlen + 1), 
"str2wstr");
+       }
+
        /*
         * Don't convert global null string or global null field
         * variables to a wide string. They are both zero-length anyway.
@@ -848,18 +860,6 @@ str2wstr(NODE *n, size_t **ptr)
        emalloc(n->wstptr, wchar_t *, sizeof(wchar_t) * (n->stlen + 1), 
"str2wstr");
        wsp = n->wstptr;
 
-       /*
-        * For use by do_match, create and fill in an array.
-        * For each byte `i' in n->stptr (the original string),
-        * a[i] is equal to `j', where `j' is the corresponding wchar_t
-        * in the converted wide string.
-        *
-        * Create the array.
-        */
-       if (ptr != NULL) {
-               ezalloc(*ptr, size_t *, sizeof(size_t) * (n->stlen + 1), 
"str2wstr");
-       }
-
        sp = n->stptr;
        src_count = n->stlen;
        memset(& mbs, 0, sizeof(mbs));



reply via email to

[Prev in Thread] Current Thread [Next in Thread]