From 05ccf1024b661c31fade62fd8c2407067ab2d70e Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Mon, 21 Dec 2015 12:06:04 +0900 Subject: 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. --- gettext-tools/src/cldr-plurals.c | 18 ++++++++++-------- 1 file 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); -- cgit v1.1