1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-24 21:33:51 +03:00

Stop using sprintf

Switch remaining users to snprintf.
This commit is contained in:
Nick Wellnhofer 2023-05-08 23:33:04 +02:00
parent 01723fc68f
commit f24ffddbb9
2 changed files with 9 additions and 7 deletions

View File

@ -1508,11 +1508,12 @@ xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
int size;
size = snprintf(NULL, 0, "%0g", eval->floatval);
buf = (xmlChar*) malloc(size);
/* xmlStrPrintf(buf, size, "%0g", eval->floatval); // doesn't work */
sprintf((char*) buf, "%0g", eval->floatval);
ret = xmlStrcat(ret, buf);
free(buf);
buf = (xmlChar *) xmlMalloc(size + 1);
if (buf != NULL) {
snprintf((char *) buf, size + 1, "%0g", eval->floatval);
ret = xmlStrcat(ret, buf);
xmlFree(buf);
}
break;
}
case XPATH_STRING:

View File

@ -216,11 +216,12 @@ xzFile
__libxml2_xzdopen(int fd, const char *mode)
{
char *path; /* identifier for error messages */
size_t path_size = 7 + 3 * sizeof(int);
xzFile xz;
if (fd == -1 || (path = xmlMalloc(7 + 3 * sizeof(int))) == NULL)
if (fd == -1 || (path = xmlMalloc(path_size)) == NULL)
return NULL;
sprintf(path, "<fd:%d>", fd); /* for debugging */
snprintf(path, path_size, "<fd:%d>", fd); /* for debugging */
xz = xz_open(path, fd, mode);
xmlFree(path);
return xz;