[njs] Improved checking that filename is not empty.

Dmitry Volyntsev xeioex at nginx.com
Tue Feb 26 15:24:30 UTC 2019


details:   https://hg.nginx.org/njs/rev/f70566bc1e62
branches:  
changeset: 806:f70566bc1e62
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Tue Feb 26 17:11:50 2019 +0300
description:
Improved checking that filename is not empty.

file->start can be non NULL for empty string.

diffstat:

 njs/njs_parser.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r 488278bde04a -r f70566bc1e62 njs/njs_parser.c
--- a/njs/njs_parser.c	Tue Feb 26 17:11:47 2019 +0300
+++ b/njs/njs_parser.c	Tue Feb 26 17:11:50 2019 +0300
@@ -233,7 +233,7 @@ njs_parser_scope_begin(njs_vm_t *vm, njs
     scope->values[0] = values;
     scope->values[1] = NULL;
 
-    if (parser->lexer->file.start != NULL) {
+    if (parser->lexer->file.length != 0) {
         ret = njs_name_copy(vm, &scope->file, &parser->lexer->file);
         if (nxt_slow_path(ret != NXT_OK)) {
             return NXT_ERROR;
@@ -2758,7 +2758,7 @@ njs_parser_trace_handler(nxt_trace_t *tr
     if (vm->parser != NULL) {
         lexer = vm->parser->lexer;
 
-        if (lexer->file.start != NULL) {
+        if (lexer->file.length != 0) {
             njs_internal_error(vm, "%s in %V:%uD", start, &lexer->file,
                                lexer->line);
         } else {
@@ -2795,7 +2795,7 @@ njs_parser_scope_error(njs_vm_t *vm, njs
         p = end - width;
     }
 
-    if (file->start != NULL) {
+    if (file->length != 0) {
         p = nxt_sprintf(p, end, " in %V:%uD", file, line);
 
     } else {


More information about the nginx-devel mailing list