[njs] Fixed njs_string_slice().

Dmitry Volyntsev xeioex at nginx.com
Fri Sep 14 11:19:23 UTC 2018


details:   http://hg.nginx.org/njs/rev/85f57cc123c2
branches:  
changeset: 605:85f57cc123c2
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Fri Sep 14 14:19:03 2018 +0300
description:
Fixed njs_string_slice().

dst retval argument was ignored.

diffstat:

 njs/njs_string.c |  6 +++---
 njs/njs_string.h |  2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r c4f9a4948697 -r 85f57cc123c2 njs/njs_string.c
--- a/njs/njs_string.c	Thu Sep 13 18:46:02 2018 +0300
+++ b/njs/njs_string.c	Fri Sep 14 14:19:03 2018 +0300
@@ -1288,7 +1288,7 @@ njs_string_slice_args(njs_slice_prop_t *
 
 nxt_noinline njs_ret_t
 njs_string_slice(njs_vm_t *vm, njs_value_t *dst,
-    const njs_string_prop_t *string, njs_slice_prop_t *slice)
+    const njs_string_prop_t *string, const njs_slice_prop_t *slice)
 {
     size_t        size, n, length;
     const u_char  *p, *start, *end;
@@ -1325,10 +1325,10 @@ njs_string_slice(njs_vm_t *vm, njs_value
     }
 
     if (nxt_fast_path(size != 0)) {
-        return njs_string_new(vm, &vm->retval, start, size, length);
+        return njs_string_new(vm, dst, start, size, length);
     }
 
-    vm->retval = njs_string_empty;
+    *dst = njs_string_empty;
 
     return NXT_OK;
 }
diff -r c4f9a4948697 -r 85f57cc123c2 njs/njs_string.h
--- a/njs/njs_string.h	Thu Sep 13 18:46:02 2018 +0300
+++ b/njs/njs_string.h	Fri Sep 14 14:19:03 2018 +0300
@@ -146,7 +146,7 @@ njs_ret_t njs_string_constructor(njs_vm_
 nxt_bool_t njs_string_eq(const njs_value_t *val1, const njs_value_t *val2);
 nxt_int_t njs_string_cmp(const njs_value_t *val1, const njs_value_t *val2);
 njs_ret_t njs_string_slice(njs_vm_t *vm, njs_value_t *dst,
-    const njs_string_prop_t *string, njs_slice_prop_t *slice);
+    const njs_string_prop_t *string, const njs_slice_prop_t *slice);
 const u_char *njs_string_offset(const u_char *start, const u_char *end,
     size_t index);
 nxt_noinline uint32_t njs_string_index(njs_string_prop_t *string,


More information about the nginx-devel mailing list