diff options
-rw-r--r-- | hw/s390x/s390-virtio-ccw.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 8cc2f25d8a..403d30e13b 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -701,8 +701,12 @@ bool hpage_1m_allowed(void) static char *machine_get_loadparm(Object *obj, Error **errp) { S390CcwMachineState *ms = S390_CCW_MACHINE(obj); + char *loadparm_str; - return g_memdup(ms->loadparm, sizeof(ms->loadparm)); + /* make a NUL-terminated string */ + loadparm_str = g_memdup(ms->loadparm, sizeof(ms->loadparm) + 1); + loadparm_str[sizeof(ms->loadparm)] = 0; + return loadparm_str; } static void machine_set_loadparm(Object *obj, const char *val, Error **errp) |