summaryrefslogtreecommitdiff
path: root/qemu-malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'qemu-malloc.c')
-rw-r--r--qemu-malloc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/qemu-malloc.c b/qemu-malloc.c
index 606eda6ff0..8ad616847a 100644
--- a/qemu-malloc.c
+++ b/qemu-malloc.c
@@ -56,9 +56,10 @@ void *qemu_mallocz(size_t size)
char *qemu_strdup(const char *str)
{
char *ptr;
- ptr = qemu_malloc(strlen(str) + 1);
+ size_t len = strlen(str);
+ ptr = qemu_malloc(len + 1);
if (!ptr)
return NULL;
- strcpy(ptr, str);
+ pstrcpy(ptr, len, str);
return ptr;
}