diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c index d80c0bad5..a8520bb0a 100644 --- a/lib/format_text/archiver.c +++ b/lib/format_text/archiver.c @@ -65,6 +65,8 @@ int archive_init(struct cmd_context *cmd, const char *dir, void archive_exit(struct cmd_context *cmd) { + if (!cmd->archive_params) + return; if (cmd->archive_params->dir) dm_free(cmd->archive_params->dir); memset(cmd->archive_params, 0, sizeof(*cmd->archive_params)); @@ -175,6 +177,8 @@ int backup_init(struct cmd_context *cmd, const char *dir, void backup_exit(struct cmd_context *cmd) { + if (!cmd->backup_params) + return; if (cmd->backup_params->dir) dm_free(cmd->backup_params->dir); memset(cmd->backup_params, 0, sizeof(*cmd->backup_params)); diff --git a/lib/label/label.c b/lib/label/label.c index 8924735d3..25f520a0c 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -72,7 +72,7 @@ void label_exit(void) struct dm_list *c, *n; struct labeller_i *li; - for (c = _labellers.n; c != &_labellers; c = n) { + for (c = _labellers.n; c && c != &_labellers; c = n) { n = c->n; li = dm_list_item(c, struct labeller_i); li->l->ops->destroy(li->l);