1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-24 06:50:08 +03:00

schemas: fix spurious warning about truncated snprintf output

Fix warning:

    xmlschemas.c: In function 'xmlSchemaVAttributesComplex':
    xmlschemas.c:25506:63: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
    xmlschemas.c:25506:29: note: 'snprintf' output between 3 and 13 bytes into a destination of size 12

On my system (GCC 13.2.1 x86_64) the warning only appears with -O0.
counter can't exceed 1000, so there's no real bug.
This commit is contained in:
Benjamin Gilbert 2024-03-02 17:02:30 +09:00
parent 25afd931fc
commit 653ef99902

View File

@ -25495,7 +25495,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
ns = xmlSearchNsByHref(defAttrOwnerElem->doc,
defAttrOwnerElem, iattr->nsName);
if (ns == NULL) {
xmlChar prefix[12];
xmlChar prefix[13];
int counter = 0;
/*
@ -25503,7 +25503,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
* root node if no namespace declaration is in scope.
*/
do {
snprintf((char *) prefix, 12, "p%d", counter++);
snprintf((char *) prefix, 13, "p%d", counter++);
ns = xmlSearchNs(defAttrOwnerElem->doc,
defAttrOwnerElem, BAD_CAST prefix);
if (counter > 1000) {