From 32e5232388fad6eeb9675ed402e3c9958eafc459 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@c-s.fr> Date: Fri, 7 Dec 2007 15:02:49 +0000 Subject: [PATCH] =?UTF-8?q?correction=20erreur=20d'allocation=20m=C3=A9moi?= =?UTF-8?q?re=20dans=20les=20svm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Utilities/otbsvm/svm.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Utilities/otbsvm/svm.cxx b/Utilities/otbsvm/svm.cxx index 4bde4ebe42..f24fdaee87 100644 --- a/Utilities/otbsvm/svm.cxx +++ b/Utilities/otbsvm/svm.cxx @@ -2908,8 +2908,22 @@ out: for(i=0;i<m;i++) model->sv_coef[i] = Malloc(double,l); model->SV = Malloc(svm_node*,l); + for(unsigned int n = 0;n<l;++n) + { + model->SV[n]=Malloc(svm_node,1); + model->SV[n]->index = -1; + model->SV[n]->value = 0.; + } svm_node *x_space=NULL; - if(l>0) x_space = Malloc(svm_node,elements); + if(l>0) + { + x_space = Malloc(svm_node,elements); + for(unsigned int n = 0;n<elements;++n) + { + x_space[n].index = -1; + x_space[n].value = 0.; + } + } int j=0; for(i=0;i<l;i++) -- GitLab