Unverified Commit 2a4fed96 by Christian Brauner Committed by Stéphane Graber

conf: move_ptr() in all cases in mapped_hostid_add()

Closes #3366. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 37fcb9bc
......@@ -3915,18 +3915,19 @@ static struct id_map *mapped_hostid_add(const struct lxc_conf *conf, uid_t id,
/* Reuse existing mapping. */
tmp = find_mapped_hostid_entry(conf, id, type);
if (tmp)
return memcpy(entry, tmp, sizeof(*entry));
/* Find new mapping. */
hostid_mapped = find_unmapped_nsid(conf, type);
if (hostid_mapped < 0)
return log_debug(NULL, "Failed to find free mapping for id %d", id);
entry->idtype = type;
entry->nsid = hostid_mapped;
entry->hostid = (unsigned long)id;
entry->range = 1;
if (tmp) {
memcpy(entry, tmp, sizeof(*entry));
} else {
/* Find new mapping. */
hostid_mapped = find_unmapped_nsid(conf, type);
if (hostid_mapped < 0)
return log_debug(NULL, "Failed to find free mapping for id %d", id);
entry->idtype = type;
entry->nsid = hostid_mapped;
entry->hostid = (unsigned long)id;
entry->range = 1;
}
return move_ptr(entry);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment