From 79e63a8fe65d349724c4d6f99b54d6867dc5cbf6 Mon Sep 17 00:00:00 2001 From: Sauyon Lee Date: Tue, 18 Sep 2018 12:21:29 -0700 Subject: [PATCH] replace malloc/strcpy pair with strdup to allocate correct size --- libgamestream/xml.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libgamestream/xml.c b/libgamestream/xml.c index d7076bc3..eaa3f49c 100644 --- a/libgamestream/xml.c +++ b/libgamestream/xml.c @@ -118,11 +118,8 @@ static void XMLCALL _xml_start_status_element(void *userData, const char *name, for (int i = 0; atts[i]; i += 2) { if (strcmp("status_code", atts[i]) == 0) *status = atoi(atts[i + 1]); - else if (*status != STATUS_OK && strcmp("status_message", atts[i]) == 0) { - gs_error = malloc(strlen(atts[i + 1])); - if (gs_error) - strcpy((char*) gs_error, atts[i + 1]); - } + else if (*status != STATUS_OK && strcmp("status_message", atts[i]) == 0) + gs_error = strdup(atts[i + 1]); } } }