From a4091189b014566dd40d3bb35c22c620e041d1e4 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 1 Mar 2024 23:09:21 +0100 Subject: [PATCH] cleanup: use proper size when allocating string Signed-off-by: Berthold Stoeger --- core/parse-xml.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/parse-xml.c b/core/parse-xml.c index ecde453e6..895571c7e 100644 --- a/core/parse-xml.c +++ b/core/parse-xml.c @@ -2261,7 +2261,7 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size, struct divelog *log) /* Recording the starting battery status to extra data */ if (battery_start.volt1) { size_t stringsize = snprintf(NULL, 0, "%dmV (%d%%)", battery_start.volt1, battery_start.percent1) + 1; - char *ptr = malloc(size); + char *ptr = malloc(stringsize); if (ptr) { snprintf(ptr, stringsize, "%dmV (%d%%)", battery_start.volt1, battery_start.percent1);