nlopt_unset_errmsg(opt);
if (opt && (opt->n == 0 || lb)) {
unsigned int i;
- memcpy(opt->lb, lb, sizeof(double) * (opt->n));
+ if (opt->n > 0)
+ memcpy(opt->lb, lb, sizeof(double) * (opt->n));
for (i = 0; i < opt->n; ++i)
if (opt->lb[i] < opt->ub[i] && nlopt_istiny(opt->ub[i] - opt->lb[i]))
opt->lb[i] = opt->ub[i];
nlopt_unset_errmsg(opt);
if (opt && (opt->n == 0 || ub)) {
unsigned int i;
- memcpy(opt->ub, ub, sizeof(double) * (opt->n));
+ if (opt->n > 0)
+ memcpy(opt->ub, ub, sizeof(double) * (opt->n));
for (i = 0; i < opt->n; ++i)
if (opt->lb[i] < opt->ub[i] && nlopt_istiny(opt->ub[i] - opt->lb[i]))
opt->ub[i] = opt->lb[i];