aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gwin/list.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/gwin/list.c b/src/gwin/list.c
index 0f09e86e..972ea1ab 100644
--- a/src/gwin/list.c
+++ b/src/gwin/list.c
@@ -431,13 +431,14 @@ int gwinListAddItem(GHandle gh, const char* item_name, bool_t useAlloc) {
ListItem *newItem;
if (useAlloc) {
- if (!(newItem = (ListItem *)gfxAlloc(sizeof(ListItem)+strlen(item_name)+1)))
+ size_t len = strlen(item_name)+1;
+ if (!(newItem = gfxAlloc(sizeof(ListItem) + len)))
return -1;
- strcpy((char *)(newItem+1), item_name);
+ memcpy((char *)(newItem+1), item_name, len);
item_name = (const char *)(newItem+1);
} else {
- if (!(newItem = (ListItem *)gfxAlloc(sizeof(ListItem))))
+ if (!(newItem = gfxAlloc(sizeof(ListItem))))
return -1;
}