summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2017-01-18 10:43:45 -0500
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2017-01-18 10:43:45 -0500
commitf7d8956c4fd8324667060933c2c30112e6c80507 (patch)
treeb6bf9e141896fa22935fc8cd752495efcc74e8b9
parentc04fec1b8c96e2b11d451fc45cfd1cf38420310f (diff)
downloadgawk-f7d8956c4fd8324667060933c2c30112e6c80507.tar.gz
Improve robustness of Op_assign_concat optimization.
-rw-r--r--ChangeLog7
-rw-r--r--interpret.h11
2 files changed, 13 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index ea490add..3650a30a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-01-18 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * interpret.h (r_interpret): Increase robustness of the optimization
+ logic in Op_assign_concat -- check that the node has MALLOC set,
+ and make sure to wipe all flags other than MALLOC, STRING, STRCUR,
+ and possibly WSTRCUR. Use STFMT_UNUSED define.
+
2017-01-15 Andrew J. Schorr <aschorr@telemetry-investments.com>
* interpret.h (r_interpret): Fix bug in Op_assign_concat reported
diff --git a/interpret.h b/interpret.h
index 3526325e..9661910a 100644
--- a/interpret.h
+++ b/interpret.h
@@ -718,16 +718,18 @@ mod:
*lhs = dupnode(t1);
}
- if (t1 != t2 && t1->valref == 1 && (t1->flags & (MPFN|MPZN)) == 0) {
+ if (t1 != t2 && t1->valref == 1 && (t1->flags & (MALLOC|MPFN|MPZN)) == MALLOC) {
size_t nlen = t1->stlen + t2->stlen;
erealloc(t1->stptr, char *, nlen + 1, "r_interpret");
memcpy(t1->stptr + t1->stlen, t2->stptr, t2->stlen);
t1->stlen = nlen;
t1->stptr[nlen] = '\0';
- t1->flags &= ~(NUMCUR|NUMBER|USER_INPUT|NUMINT|INTIND);
- t1->flags |= (STRING|STRCUR);
- t1->stfmt = -1;
+ /* clear flags except WSTRCUR (used below) */
+ t1->flags &= WSTRCUR;
+ /* configure as a string as in make_str_node */
+ t1->flags |= (MALLOC|STRING|STRCUR);
+ t1->stfmt = STFMT_UNUSED;
if ((t1->flags & WSTRCUR) != 0 && (t2->flags & WSTRCUR) != 0) {
size_t wlen = t1->wstlen + t2->wstlen;
@@ -737,7 +739,6 @@ mod:
memcpy(t1->wstptr + t1->wstlen, t2->wstptr, t2->wstlen * sizeof(wchar_t));
t1->wstlen = wlen;
t1->wstptr[wlen] = L'\0';
- t1->flags |= WSTRCUR;
} else
free_wstr(*lhs);
} else {