]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
cldr-plurals: Fix errors from clang-analyzer
authorDaiki Ueno <ueno@gnu.org>
Mon, 21 Dec 2015 03:06:04 +0000 (12:06 +0900)
committerDaiki Ueno <ueno@gnu.org>
Mon, 21 Dec 2015 03:08:00 +0000 (12:08 +0900)
* gettext-tools/src/cldr-plurals.c (extract_rules): Add extra null
checks for NODE and BUFFER.  Don't add NUL byte to the end of buffer
manually.

gettext-tools/src/cldr-plurals.c

index ee3b3c6b1862ed82f73ff9c4a32374b0276516b9..abbd0c238a5c0a718f2675490a92dedd6731ffee 100644 (file)
@@ -61,14 +61,14 @@ extract_rules (FILE *fp,
     error (EXIT_FAILURE, 0, _("memory exhausted"));
 
   node = xmlDocGetRootElement (doc);
-  if (node && !xmlStrEqual (node->name, BAD_CAST "supplementalData"))
+  if (!node || !xmlStrEqual (node->name, BAD_CAST "supplementalData"))
     {
       error_at_line (0, 0,
                      logical_filename,
                      xmlGetLineNo (node),
                      _("\
-The root element <%s> is not allowed in a valid CLDR file"),
-                     node->name);
+The root element must be <%s>"),
+                     "supplementalData");
       goto out;
     }
 
@@ -167,14 +167,16 @@ The element <%s> does not have attribute <%s>"),
           xmlFree (content);
 
           buflen += length;
-          buffer[buflen] = '\0';
         }
     }
 
-  /* Scrub the last semicolon, if any.  */
-  p = strrchr (buffer, ';');
-  if (p)
-    *p = '\0';
+  if (buffer)
+    {
+      /* Scrub the last semicolon, if any.  */
+      p = strrchr (buffer, ';');
+      if (p)
+        *p = '\0';
+    }
 
  out:
   xmlFreeDoc (doc);