summaryrefslogtreecommitdiffstats
path: root/gettext-tools/src
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2015-12-21 12:06:04 +0900
committerDaiki Ueno <ueno@gnu.org>2015-12-21 12:08:00 +0900
commit05ccf1024b661c31fade62fd8c2407067ab2d70e (patch)
tree6405ec587f3cffd564c4eabc6e5eef1288141809 /gettext-tools/src
parent7d14c54656daa726998f3264f385167c9c64e284 (diff)
downloadexternal_gettext-05ccf1024b661c31fade62fd8c2407067ab2d70e.zip
external_gettext-05ccf1024b661c31fade62fd8c2407067ab2d70e.tar.gz
external_gettext-05ccf1024b661c31fade62fd8c2407067ab2d70e.tar.bz2
cldr-plurals: Fix errors from clang-analyzer
* 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.
Diffstat (limited to 'gettext-tools/src')
-rw-r--r--gettext-tools/src/cldr-plurals.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/gettext-tools/src/cldr-plurals.c b/gettext-tools/src/cldr-plurals.c
index ee3b3c6..abbd0c2 100644
--- a/gettext-tools/src/cldr-plurals.c
+++ b/gettext-tools/src/cldr-plurals.c
@@ -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);