diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2017-01-27 13:25:02 -0500 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2017-01-27 13:25:02 -0500 |
commit | a7addf98875555f48f30e7a9260f39a36a7b3e75 (patch) | |
tree | 585ab531aaf54a667a4b5618bf9b476d0eaf4793 /interpret.h | |
parent | f1507d4056a6f4e2a9cd5091a495175cbfb840ae (diff) | |
download | egawk-a7addf98875555f48f30e7a9260f39a36a7b3e75.tar.gz egawk-a7addf98875555f48f30e7a9260f39a36a7b3e75.tar.bz2 egawk-a7addf98875555f48f30e7a9260f39a36a7b3e75.zip |
Introduce some helpful macros for terminating strings, and fix overrun in dcgettext.
Diffstat (limited to 'interpret.h')
-rw-r--r-- | interpret.h | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/interpret.h b/interpret.h index 191e1efb..13394e22 100644 --- a/interpret.h +++ b/interpret.h @@ -912,15 +912,14 @@ mod: sort_str = force_string(sort_str); if (sort_str->stlen > 0) { how_to_sort = sort_str->stptr; - save = sort_str->stptr[sort_str->stlen]; - sort_str->stptr[sort_str->stlen] = '\0'; + str_terminate(sort_str, save); saved_end = true; } } list = assoc_list(array, how_to_sort, SORTED_IN); if (saved_end) - sort_str->stptr[sort_str->stlen] = save; + str_restore(sort_str, save); arrayfor: getnode(r); @@ -1066,15 +1065,14 @@ match_re: fatal(_("indirect function call requires a simple scalar value")); t1 = force_string(t1); - save = t1->stptr[t1->stlen]; - t1->stptr[t1->stlen] = '\0'; + str_terminate(t1, save); if (t1->stlen > 0) { /* retrieve function definition node */ f = pc->func_body; if (f != NULL && strcmp(f->vname, t1->stptr) == 0) { /* indirect var hasn't been reassigned */ - t1->stptr[t1->stlen] = save; + str_restore(t1, save); ni = setup_frame(pc); JUMPTO(ni); /* Op_func */ } @@ -1099,12 +1097,12 @@ match_re: r = call_split_func(t1->stptr, arg_count); else r = the_func(arg_count); - t1->stptr[t1->stlen] = save; + str_restore(t1, save); PUSH(r); break; } else if (f->type != Node_func) { - t1->stptr[t1->stlen] = save; + str_restore(t1, save); if (f->type == Node_ext_func) { /* code copied from below, keep in sync */ INSTRUCTION *bc; @@ -1129,7 +1127,7 @@ match_re: pc->func_name); } pc->func_body = f; /* save for next call */ - t1->stptr[t1->stlen] = save; + str_restore(t1, save); ni = setup_frame(pc); JUMPTO(ni); /* Op_func */ |