diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | awk.h | 7 |
2 files changed, 12 insertions, 0 deletions
@@ -1,5 +1,10 @@ 2016-06-27 Andrew J. Schorr <aschorr@telemetry-investments.com> + * awk.h: Add a comment regarding the potential lack of NUL-termination + for Node_val strings. + +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 @@ -476,6 +476,13 @@ typedef struct exp_node { #define re_cnt flags /* Node_val */ +/* + * Note that the string in stptr may not be NUL-terminated, but it is + * guaranteed to have at least one extra byte that may be temporarily set + * to '\0'. This is helpful when calling functions such as strtod that require + * a NUL-terminated argument. In particular, field values $n for n > 0 and + * n < NF will not have a NUL terminator, since they point into the $0 buffer. + */ #define stptr sub.val.sp #define stlen sub.val.slen #define valref sub.val.sref |