[njs] Fixed RegExp trace handlers.

Dmitry Volyntsev xeioex at nginx.com
Thu Mar 15 12:15:46 UTC 2018


details:   http://hg.nginx.org/njs/rev/218db4540b15
branches:  
changeset: 459:218db4540b15
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Thu Mar 15 15:15:23 2018 +0300
description:
Fixed RegExp trace handlers.

Found by Clang Static Analyzer.

diffstat:

 njs/njs_regexp.c |  12 +-----------
 1 files changed, 1 insertions(+), 11 deletions(-)

diffs (36 lines):

diff -r 895355fde02c -r 218db4540b15 njs/njs_regexp.c
--- a/njs/njs_regexp.c	Wed Mar 14 14:32:24 2018 +0300
+++ b/njs/njs_regexp.c	Thu Mar 15 15:15:23 2018 +0300
@@ -386,13 +386,8 @@ njs_regexp_compile_trace_handler(nxt_tra
     u_char *start)
 {
     u_char    *p;
-    size_t    size;
     njs_vm_t  *vm;
 
-    size = sizeof("SyntaxError: ") - 1;
-    memcpy(start, "SyntaxError: ", size);
-    p = start + size;
-
     vm = trace->data;
 
     trace = trace->next;
@@ -433,17 +428,12 @@ njs_regexp_match_trace_handler(nxt_trace
     u_char *start)
 {
     u_char    *p;
-    size_t    size;
     njs_vm_t  *vm;
 
-    size = sizeof("InternalError: ") - 1;
-    memcpy(start, "InternalError: ", size);
-    p = start + size;
-
     vm = trace->data;
 
     trace = trace->next;
-    p = trace->handler(trace, td, p);
+    p = trace->handler(trace, td, start);
 
     njs_exception_internal_error(vm, (const char *) start, NULL);
 


More information about the nginx-devel mailing list