From 00f7bf06011811c9c046155c59d8a37dea4ea4d3 Mon Sep 17 00:00:00 2001 From: Maschell Date: Tue, 24 Jan 2023 14:39:48 +0100 Subject: [PATCH] StorageAPI: Use strdup if possible --- libraries/libwups/storage.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/libwups/storage.cpp b/libraries/libwups/storage.cpp index b303e3a..eb0e00c 100644 --- a/libraries/libwups/storage.cpp +++ b/libraries/libwups/storage.cpp @@ -245,13 +245,12 @@ static wups_storage_item_t *addItem(wups_storage_item_t *parent, const char *key parent->data_size += INCREASE_SIZE_BY; - foundItem->key = (char *) malloc(strlen(key) + 1); + foundItem->key = strdup(key); if (foundItem->key == nullptr) { foundItem->pending_delete = true; *error = WUPS_STORAGE_ERROR_MALLOC_FAILED; return nullptr; } - strcpy(foundItem->key, key); } foundItem->type = type;