log_dbg("Creating empty file %s of size %lu.", new_file, (unsigned long)size);
- if (!(buf = malloc(size)))
+ if (!size || !(buf = malloc(size)))
return -ENOMEM;
memset(buf, 0, size);
log_dbg("Passhrases initialization.");
- if (opt_new) {
+ if (opt_new && !rc->in_progress) {
r = init_passphrase1(rc, cd, _("Enter new LUKS passphrase: "), 0, 0);
return r > 0 ? 0 : r;
}