Hi, I tried to use darktable-chart with a 'fake' chart (generated in argyllcms with printarg added a gradient by hand) so I could experiment with haldclut (which I applied via GIMP+G'MIC to this chart) and the generated styles. Now when running the generated CSV file to darktable-chart I got a SIGSEGV which I tracked down to line 150 in thinplate.c, the following patch is my fix to this.
Regards, Erwin Burema --- src/chart/thinplate.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/chart/thinplate.c b/src/chart/thinplate.c index c5ff0a9..fe8e2f1 100644 --- a/src/chart/thinplate.c +++ b/src/chart/thinplate.c @@ -30,6 +30,7 @@ #include <float.h> #include <string.h> #include <assert.h> +#include <stdlib.h> // #define REPLACEMENT // either broken code or doesn't help at all // #define EXACT // use full solve instead of dot in inner loop @@ -147,7 +148,7 @@ int thinplate_match(const tonecurve_t *curve, // tonecurve to apply after this ( // permutation[dim] { const int wd = N + 4; - double A[wd * wd]; + double *A = malloc(wd * wd * sizeof(double)); // construct system matrix A such that: // A c = f // @@ -196,7 +197,11 @@ int thinplate_match(const tonecurve_t *curve, // tonecurve to apply after this ( { const int sparsity = MIN(s, S); #ifndef REPLACEMENT - if(patches >= S - 4) return sparsity; + if(patches >= S - 4) + { + free(A); + return sparsity; + } assert(sparsity < S + 4); #endif // find (sparsity+1)-th column a_m by m = argmax_t{ a_t^t r . norm_t} @@ -217,7 +222,11 @@ int thinplate_match(const tonecurve_t *curve, // tonecurve to apply after this ( for(int i = 0; i <= sparsity; i++) for(int j = 0; j < wd; j++) As[j * S + i] = A[j * wd + permutation[i]]; - if(solve(As, w, v, b[ch], coeff[ch], wd, sparsity, S)) return sparsity; + if(solve(As, w, v, b[ch], coeff[ch], wd, sparsity, S)) + { + free(A); + return sparsity; + } // compute tentative residual: // r = b - As c @@ -274,7 +283,11 @@ int thinplate_match(const tonecurve_t *curve, // tonecurve to apply after this ( for(int i = 0; i < sparsity; i++) for(int j = 0; j < wd; j++) As[j * S + i] = A[j * wd + permutation[i]]; - if(solve(As, w, v, b[ch], coeff[ch], wd, sparsity-1, S)) return s; + if(solve(As, w, v, b[ch], coeff[ch], wd, sparsity-1, S)) + { + free(A); + return s; + } // compute tentative residual: // r = b - As c @@ -340,7 +353,11 @@ int thinplate_match(const tonecurve_t *curve, // tonecurve to apply after this ( for(int j = 0; j < wd; j++) As[j * S + i] = A[j * wd + permutation[i]]; // on error, return last valid configuration - if(solve(As, w, v, b[ch], coeff[ch], wd, sp, S)) return sparsity; + if(solve(As, w, v, b[ch], coeff[ch], wd, sp, S)) + { + free(A); + return sparsity; + } // compute new residual: // r = b - As c @@ -364,6 +381,7 @@ int thinplate_match(const tonecurve_t *curve, // tonecurve to apply after this ( // if(err < 2.0) return sparsity+1; olderr = err; } + free(A); return -1; } -- 2.7.4 ___________________________________________________________________________ darktable developer mailing list to unsubscribe send a mail to darktable-dev+unsubscr...@lists.darktable.org