From: Daiki Ueno Date: Mon, 21 Dec 2015 03:06:04 +0000 (+0900) Subject: cldr-plurals: Fix errors from clang-analyzer X-Git-Tag: v0.19.7~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05ccf1024b661c31fade62fd8c2407067ab2d70e;p=thirdparty%2Fgettext.git 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. --- diff --git a/gettext-tools/src/cldr-plurals.c b/gettext-tools/src/cldr-plurals.c index ee3b3c6b1..abbd0c238 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);