diff --git a/daemon/daemon.h b/daemon/daemon.h index 04f28bb85..1d3c65c9e 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -370,7 +370,7 @@ is_zero (const char *buffer, size_t size) */ #define RESOLVE_MOUNTABLE(string,mountable,cancel_stmt,fail_stmt) \ do { \ - if (STRPREFIX ((string), "btrfsvol:")) { \ + if (STRPREFIX ((string), "btrfsvol:")) { \ if (parse_btrfsvol ((string) + strlen ("btrfsvol:"), &(mountable)) == -1)\ { \ cancel_stmt; \ @@ -383,6 +383,7 @@ is_zero (const char *buffer, size_t size) else { \ (mountable).type = MOUNTABLE_DEVICE; \ (mountable).device = (string); \ + (mountable).volume = NULL; \ RESOLVE_DEVICE((string), cancel_stmt, fail_stmt); \ } \ } while (0) diff --git a/daemon/mountable.c b/daemon/mountable.c index 610633ee9..48c6c53f7 100644 --- a/daemon/mountable.c +++ b/daemon/mountable.c @@ -36,23 +36,28 @@ do_internal_parse_mountable (const mountable_t *mountable) } ret->im_type = mountable->type; - if (mountable->device) { + + if (mountable->device) ret->im_device = strdup (mountable->device); - if (!ret->im_device) { - reply_with_perror ("strdup"); - free (ret); - return NULL; - } + else + ret->im_device = strdup (""); + + if (!ret->im_device) { + reply_with_perror ("strdup"); + free (ret); + return NULL; } - if (mountable->volume) { + if (mountable->volume) ret->im_volume = strdup (mountable->volume); - if (!ret->im_volume) { - reply_with_perror ("strdup"); - free (ret->im_device); - free (ret); - return NULL; - } + else + ret->im_volume = strdup (""); + + if (!ret->im_volume) { + reply_with_perror ("strdup"); + free (ret->im_device); + free (ret); + return NULL; } return ret;