summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2023-03-02 21:10:35 +0200
committerArnold D. Robbins <arnold@skeeve.com>2023-03-02 21:10:35 +0200
commit39b80c56897978129ac2a5edc97fe92ea577e86c (patch)
treedc2f877d4b54f81f75c5b0d183c48d114c1bb583
parentd5c88fbbbc92b80f424d35e5fd8cf3ede854dd87 (diff)
downloadgawk-39b80c56897978129ac2a5edc97fe92ea577e86c.tar.gz
Revert change to Op_field_spec_lhs of 2023-01-23.
-rw-r--r--ChangeLog10
-rw-r--r--interpret.h16
2 files changed, 11 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 4bf60db4..0ee46a69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-03-02 Arnold D. Robbins <arnold@skeeve.com>
+
+ * interpret.h (r_interpret): Revert this change of 2023-01-23,
+ it's handled by the fix of 2023-02-27.
+
+ | * interpret.h (r_interpret): Op_assign case, don't unref the
+ | old lhs NODE until after the assignment. See test case in
+ | the comment in the code and test/fieldassign.awk. Thanks to
+ | Yasuhiro Yamada <yamada@gr3.ie> for the report.
+
2023-02-27 Arnold D. Robbins <arnold@skeeve.com>
* gawkmisc.c: Use #elif. Update copyright year.
diff --git a/interpret.h b/interpret.h
index d9f97b1b..70195d96 100644
--- a/interpret.h
+++ b/interpret.h
@@ -879,30 +879,16 @@ mod:
break;
case Op_assign:
- {
- NODE *save_lhs;
-
lhs = POP_ADDRESS();
r = TOP_SCALAR();
- /*
- * 1/2023:
- * The old NODE pointed to by *lhs has to be freed.
- * But we can't free it too early, in case it's both $0 and $1
- * (Test case was gawk 'gsub(/./, "@") && $0=$1'). So we save
- * the old one, and after the assignment, we free it, since
- * $0 and $1 have the same stptr value but only $0 has MALLOC
- * in the flags. Whew!
- */
- save_lhs = *lhs;
+ unref(*lhs);
if (r->type == Node_elem_new) {
DEREF(r);
r = dupnode(Nnull_string);
}
UPREF(r);
UNFIELD(*lhs, r);
- unref(save_lhs);
REPLACE(r);
- }
break;
case Op_subscript_assign: