diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2016-06-27 19:48:34 -0400 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2016-06-27 19:48:34 -0400 |
commit | e4863f1b6341cbcc4132a8161e000e81092b4d65 (patch) | |
tree | 65f009b3406b96a950290328d88f2c22ed8f4959 | |
parent | a7b4445ceb1d355911a8a367b8db79b225094c43 (diff) | |
download | egawk-e4863f1b6341cbcc4132a8161e000e81092b4d65.tar.gz egawk-e4863f1b6341cbcc4132a8161e000e81092b4d65.tar.bz2 egawk-e4863f1b6341cbcc4132a8161e000e81092b4d65.zip |
Protect against an improper call to free in r_format_val.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | node.c | 2 |
2 files changed, 8 insertions, 1 deletions
@@ -1,3 +1,10 @@ +2016-06-27 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * node.c (r_format_val): Do not free stptr unless STRCUR is set. + This is safer than testing for non-NULL stptr, since, for example, + pp_number copies a node and calls r_format_val, but does not bother + to set stptr to NULL beforehand. + 2016-06-26 Andrew J. Schorr <aschorr@telemetry-investments.com> * node.c (r_force_number): When checking for trailing spaces, protect @@ -272,7 +272,7 @@ r_format_val(const char *format, int index, NODE *s) s->flags |= STRING; } } - if (s->stptr != NULL) + if ((s->flags & STRCUR) != 0) efree(s->stptr); emalloc(s->stptr, char *, s->stlen + 1, "format_val"); memcpy(s->stptr, sp, s->stlen + 1); |