diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2017-08-17 20:33:20 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2017-08-17 20:33:20 +0300 |
commit | e2efe866b0fe0b697f633612893da5e74034a47c (patch) | |
tree | e061a9cbfd22bfdd9662b604544261aeedf3e995 | |
parent | 833b375c19c372f13648e4f88f4177dad7350c5e (diff) | |
download | egawk-e2efe866b0fe0b697f633612893da5e74034a47c.tar.gz egawk-e2efe866b0fe0b697f633612893da5e74034a47c.tar.bz2 egawk-e2efe866b0fe0b697f633612893da5e74034a47c.zip |
Fix reference counting management problem in rebuild_record().
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | field.c | 10 |
2 files changed, 9 insertions, 7 deletions
@@ -1,3 +1,9 @@ +2017-08-17 Arnold D. Robbins <arnold@skeeve.com> + + * field.c (rebuild_record): Set new fields valref to 1 if + original field's valref was > 1. Update the comment. Found + by running chem. + 2017-08-16 Arnold D. Robbins <arnold@skeeve.com> * gawkapi.c (assign_number): Clean up the code a bit. @@ -217,20 +217,16 @@ rebuild_record() *n = *r; if (r->valref > 1) { /* - * This probably never happens, since it - * was not considered by previous versions of - * this function. But it seems clear that + * This can and does happen. It seems clear that * we can't leave r's stptr pointing into the * old $0 buffer that we are about to unref. - * It's not a priori obvious that valref must be - * 1 in all cases, so it seems wise to suppport - * this corner case. The only question is - * whether to add a warning message. */ emalloc(r->stptr, char *, r->stlen + 1, "rebuild_record"); memcpy(r->stptr, cops, r->stlen); r->stptr[r->stlen] = '\0'; r->flags |= MALLOC; + + n->valref = 1; // reset in the new field to start it off correctly! } n->stptr = cops; |