StorageAPI: Use strdup if possible

This commit is contained in:
Maschell 2023-01-24 14:39:48 +01:00
parent 52ac0d0c7a
commit 00f7bf0601

View File

@ -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;