[njs] XML: fixed compilation with certain GCC versions.

Dmitry Volyntsev xeioex at nginx.com
Thu Oct 19 01:50:44 UTC 2023


details:   https://hg.nginx.org/njs/rev/3a7526c8694c
branches:  
changeset: 2222:3a7526c8694c
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Wed Oct 18 18:36:00 2023 -0700
description:
XML: fixed compilation with certain GCC versions.

external/njs_xml_module.c:541:16: error: 'name.length' may be used
uninitialized [-Werror=maybe-uninitialized]
  541 |             if (name.length != njs_strlen(node->name).

diffstat:

 external/njs_xml_module.c |  5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diffs (15 lines):

diff -r c0ff44d66ffb -r 3a7526c8694c external/njs_xml_module.c
--- a/external/njs_xml_module.c	Tue Oct 17 17:51:39 2023 -0700
+++ b/external/njs_xml_module.c	Wed Oct 18 18:36:00 2023 -0700
@@ -527,6 +527,11 @@ njs_xml_doc_ext_root(njs_vm_t *vm, njs_o
             njs_value_undefined_set(retval);
             return NJS_DECLINED;
         }
+
+    } else {
+        /* To suppress warning. */
+        name.length = 0;
+        name.start = NULL;
     }
 
     for (node = xmlDocGetRootElement(tree->doc);


More information about the nginx-devel mailing list