From b8e03e13ed2441ef98538b75a80da816c5511028 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 2 Oct 2023 15:07:55 +0200 Subject: [PATCH] examples: Don't use sprintf Avoids warnings on macOS. --- doc/examples/tree2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/examples/tree2.c b/doc/examples/tree2.c index 78dcac14..ef137af6 100644 --- a/doc/examples/tree2.c +++ b/doc/examples/tree2.c @@ -80,10 +80,10 @@ main(int argc, char **argv) * A simple loop that "automates" nodes creation */ for (i = 5; i < 7; i++) { - sprintf(buff, "node%d", i); + snprintf(buff, sizeof(buff), "node%d", i); node = xmlNewChild(root_node, NULL, BAD_CAST buff, NULL); for (j = 1; j < 4; j++) { - sprintf(buff, "node%d%d", i, j); + snprintf(buff, sizeof(buff), "node%d%d", i, j); node1 = xmlNewChild(node, NULL, BAD_CAST buff, NULL); xmlNewProp(node1, BAD_CAST "odd", BAD_CAST((j % 2) ? "no" : "yes")); }