From 0bd3a94efddf913d2f24c893d78e86d050cb2749 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 3 Dec 2021 00:22:03 +0300 Subject: [PATCH] Use qdict_get_try_int because qdict_get_int may segfault on a missing key --- src/qemu_driver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qemu_driver.c b/src/qemu_driver.c index ac117864b..da09e82f6 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -251,19 +251,19 @@ static int vitastor_file_open(BlockDriverState *bs, QDict *options, int flags, E } if (!client->size) { - client->size = qdict_get_int(options, "size"); + client->size = qdict_get_try_int(options, "size", 0); } } else { client->watch = NULL; - client->inode = qdict_get_int(options, "inode"); - client->pool = qdict_get_int(options, "pool"); + client->inode = qdict_get_try_int(options, "inode", 0); + client->pool = qdict_get_try_int(options, "pool", 0); if (client->pool) { client->inode = (client->inode & ((1l << (64-POOL_ID_BITS)) - 1)) | (client->pool << (64-POOL_ID_BITS)); } - client->size = qdict_get_int(options, "size"); + client->size = qdict_get_try_int(options, "size", 0); } if (!client->size) {