From 04f8a1e03c91e686a8f10b6e9ee5f0af6aa65aff Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Thu, 16 Apr 2015 22:47:43 -0400 Subject: [PATCH] fix #26 --- api/optimize.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/optimize.c b/api/optimize.c index 2087d8f..0d679dc 100644 --- a/api/optimize.c +++ b/api/optimize.c @@ -248,10 +248,15 @@ static void elimdim_expand(unsigned n, double *v, /* given opt, create a new opt with equal-constraint dimensions eliminated */ static nlopt_opt elimdim_create(nlopt_opt opt) { - nlopt_opt opt0 = nlopt_copy(opt); + nlopt_opt opt0; + nlopt_munge munge_copy_save = opt->munge_on_copy; double *x, *grad = NULL; unsigned i; + opt->munge_on_copy = 0; /* hack: since this is an internal copy, + we can leave it un-munged; see issue #26 */ + opt0 = nlopt_copy(opt); + opt->munge_on_copy = munge_copy_save; if (!opt0) return NULL; x = (double *) malloc(sizeof(double) * opt->n); if (opt->n && !x) { nlopt_destroy(opt0); return NULL; } -- 2.30.2