[njs] Fixed use-of-uninitialized-value in njs_string_replace_join().

Dmitry Volyntsev xeioex at nginx.com
Thu Jun 20 22:36:17 UTC 2019


details:   https://hg.nginx.org/njs/rev/df8d48ea3875
branches:  
changeset: 1013:df8d48ea3875
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Thu Jun 20 15:20:34 2019 +0300
description:
Fixed use-of-uninitialized-value in njs_string_replace_join().

diffstat:

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

diffs (22 lines):

diff -r d6ffea147fd3 -r df8d48ea3875 njs/njs_string.c
--- a/njs/njs_string.c	Thu Jun 20 07:36:57 2019 -0400
+++ b/njs/njs_string.c	Thu Jun 20 15:20:34 2019 +0300
@@ -3652,12 +3652,16 @@ njs_string_replace_join(njs_vm_t *vm, nj
     n = r->parts.items;
 
     for (i = 0; i < n; i++) {
+        if (part[i].size == 0) {
+            continue;
+        }
+
+        size += part[i].size;
+
         if (part[i].start == NULL) {
             part[i].start = part[i].value.short_string.start;
         }
 
-        size += part[i].size;
-
         len = nxt_utf8_length(part[i].start, part[i].size);
 
         if (len >= 0) {


More information about the nginx-devel mailing list