[njs] Fixed njs_value_property() for NJS_DECLINED from prop handler.

Alexander Borisov alexander.borisov at nginx.com
Wed Jul 22 12:22:01 UTC 2020


details:   https://hg.nginx.org/njs/rev/436d4c253d10
branches:  
changeset: 1476:436d4c253d10
user:      Alexander Borisov <alexander.borisov at nginx.com>
date:      Wed Jul 22 15:21:14 2020 +0300
description:
Fixed njs_value_property() for NJS_DECLINED from prop handler.

This ensures retval has valid value for any case except NJS_ERROR.

diffstat:

 src/njs_value.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (18 lines):

diff -r d88b65c37ecc -r 436d4c253d10 src/njs_value.c
--- a/src/njs_value.c	Wed Jul 22 15:21:13 2020 +0300
+++ b/src/njs_value.c	Wed Jul 22 15:21:14 2020 +0300
@@ -1033,8 +1033,12 @@ slow_path:
             ret = prop->value.data.u.prop_handler(vm, prop, value, NULL,
                                                   &prop->value);
 
-            if (njs_slow_path(ret == NJS_ERROR)) {
-                return ret;
+            if (njs_slow_path(ret != NJS_OK)) {
+                if (ret == NJS_ERROR) {
+                    return ret;
+                }
+
+                njs_set_undefined(&prop->value);
             }
 
             *retval = prop->value;


More information about the nginx-devel mailing list