gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-4371-g313a4000


From: Arnold Robbins
Subject: [SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-4371-g313a4000
Date: Fri, 4 Feb 2022 06:28:28 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, gawk-5.1-stable has been updated
       via  313a4000d906aa233ce8b597031f660d6281f690 (commit)
      from  d96d55d7d23ee27c49cf7055956007de5f3432db (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=313a4000d906aa233ce8b597031f660d6281f690

commit 313a4000d906aa233ce8b597031f660d6281f690
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Fri Feb 4 13:28:10 2022 +0200

    Start fixing indirect calls of builtins.

diff --git a/ChangeLog b/ChangeLog
index 6f89d610..be2116fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2022-02-04         Arnold D. Robbins     <arnold@skeeve.com>
+
+       Start fixing issues with indirect calls of builtins.
+       Thanks to Denis Shirokov <cosmogen@gmail.com> for the initial report.
+       Much more remains to be done.
+
+       * builtin.c (do_length): Check number of arguments, fatal if not one.
+       If passed Node_var_new, turn it into the null string.
+       * interpret.h (r_interpret): For Op_indirect_call, pop the function
+       name off the stack.
+
 2022-01-05         Arnold D. Robbins     <arnold@skeeve.com>
 
        * awkgram.y (change_namespace): New function. Extracted from
diff --git a/builtin.c b/builtin.c
index 91cd142f..125468ba 100644
--- a/builtin.c
+++ b/builtin.c
@@ -538,6 +538,10 @@ do_length(int nargs)
        NODE *tmp;
        size_t len;
 
+       // indirect call can pass too many arguments
+       if (nargs != 1)
+               fatal(_("length: called with %d arguments"), nargs);
+
        tmp = POP();
        if (tmp->type == Node_var_array) {
                static bool warned = false;
@@ -561,6 +565,10 @@ do_length(int nargs)
 
                size = assoc_length(tmp);
                return make_number(size);
+       } else if (tmp->type == Node_var_new) {
+               // this can happen from an indirect call
+               DEREF(tmp);
+               tmp = dupnode(Nnull_string);
        }
 
        assert(tmp->type == Node_val);
diff --git a/interpret.h b/interpret.h
index d52d537e..071d6497 100644
--- a/interpret.h
+++ b/interpret.h
@@ -1132,6 +1132,7 @@ match_re:
                        NODE *f = NULL;
                        int arg_count;
                        char save;
+                       NODE *function_name;
 
                        arg_count = (pc + 1)->expr_count;
                        t1 = PEEK(arg_count);   /* indirect var */
@@ -1174,6 +1175,9 @@ match_re:
                                        r = the_func(arg_count);
                                str_restore(t1, save);
 
+                               function_name = POP();  // pop function name 
off stack
+                               DEREF(function_name);
+
                                PUSH(r);
                                break;
                        } else if (f->type != Node_func) {

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog   | 11 +++++++++++
 builtin.c   |  8 ++++++++
 interpret.h |  4 ++++
 3 files changed, 23 insertions(+)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]