diff --git a/libguestfs-inspect.c b/libguestfs-inspect.c index 3e0d6d0..b22c7a0 100644 --- a/libguestfs-inspect.c +++ b/libguestfs-inspect.c @@ -53,7 +53,9 @@ zmsg_t *guestfs_inspect_command_to_zmsg(struct guestfs_inpsect_command *command) return res; } -struct guestfs_inpsect_command *guestfs_inspect_zmsg_to_command(zmsg_t *msg) { +struct guestfs_inpsect_command *guestfs_inspect_zmsg_to_command(zmsg_t *external_msg) { + // This way we do not modify the argument we are given. + zmsg_t *msg = zmsg_dup(external_msg); struct guestfs_inpsect_command *res = malloc(sizeof(struct guestfs_inpsect_command)); res->name = zmsg_popstr(msg); @@ -85,6 +87,8 @@ struct guestfs_inpsect_command *guestfs_inspect_zmsg_to_command(zmsg_t *msg) { } break; } + zmsg_destroy(&msg); + return res; }