@@ -734,10 +734,10 @@ int uci_set(struct uci_context *ctx, struct uci_ptr *ptr)
strcpy(ptr->s->type, ptr->value);
} else {
struct uci_section *old = ptr->s;
- ptr->s = uci_alloc_section(ptr->p, ptr->value, ptr->section, &old->e.list);
+ ptr->s = uci_alloc_section(ptr->p, ptr->value, old->e.name, &old->e.list);
uci_section_transfer_options(ptr->s, old);
if (ptr->section == old->e.name)
- ptr->section = ptr->o->e.name;
+ ptr->section = ptr->s->e.name;
uci_free_section(old);
ptr->s->package->n_section--;
ptr->last = &ptr->s->e;