From c7a471c8c6ed85796f097019d28081f00c2b539a Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Tue, 22 Dec 2009 22:03:57 +0000 Subject: This fixes the following coverity issues: 163 162 161 Basically the function wasn't freeing memory it used before returning. Kent --- intern/opennl/superlu/sgstrf.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'intern/opennl/superlu') diff --git a/intern/opennl/superlu/sgstrf.c b/intern/opennl/superlu/sgstrf.c index 42f8dc9d0ee..e48cc33b00b 100644 --- a/intern/opennl/superlu/sgstrf.c +++ b/intern/opennl/superlu/sgstrf.c @@ -283,8 +283,12 @@ sgstrf (superlu_options_t *options, SuperMatrix *A, * -------------------------------------- */ /* Determine the union of the row structure of the snode */ if ( (*info = ssnode_dfs(jcol, kcol, asub, xa_begin, xa_end, - xprune, marker, &Glu)) != 0 ) + xprune, marker, &Glu)) != 0 ) { + if ( iperm_r_allocated ) SUPERLU_FREE (iperm_r); + SUPERLU_FREE (iperm_c); + SUPERLU_FREE (relax_end); return; + } nextu = xusub[jcol]; nextlu = xlusup[jcol]; @@ -293,8 +297,12 @@ sgstrf (superlu_options_t *options, SuperMatrix *A, new_next = nextlu + (xlsub[fsupc+1]-xlsub[fsupc])*(kcol-jcol+1); nzlumax = Glu.nzlumax; while ( new_next > nzlumax ) { - if ( (*info = sLUMemXpand(jcol, nextlu, LUSUP, &nzlumax, &Glu)) ) - return; + if ( (*info = sLUMemXpand(jcol, nextlu, LUSUP, &nzlumax, &Glu)) ) { + if ( iperm_r_allocated ) SUPERLU_FREE (iperm_r); + SUPERLU_FREE (iperm_c); + SUPERLU_FREE (relax_end); + return; + } } for (icol = jcol; icol<= kcol; icol++) { @@ -350,17 +358,31 @@ sgstrf (superlu_options_t *options, SuperMatrix *A, if ((*info = scolumn_dfs(m, jj, perm_r, &nseg, &panel_lsub[k], segrep, &repfnz[k], xprune, marker, - parent, xplore, &Glu)) != 0) return; + parent, xplore, &Glu)) != 0) { + if ( iperm_r_allocated ) SUPERLU_FREE (iperm_r); + SUPERLU_FREE (iperm_c); + SUPERLU_FREE (relax_end); + return; + } /* Numeric updates */ if ((*info = scolumn_bmod(jj, (nseg - nseg1), &dense[k], tempv, &segrep[nseg1], &repfnz[k], - jcol, &Glu, stat)) != 0) return; + jcol, &Glu, stat)) != 0) { + if ( iperm_r_allocated ) SUPERLU_FREE (iperm_r); + SUPERLU_FREE (iperm_c); + SUPERLU_FREE (relax_end); + return; + } /* Copy the U-segments to ucol[*] */ if ((*info = scopy_to_ucol(jj, nseg, segrep, &repfnz[k], - perm_r, &dense[k], &Glu)) != 0) - return; + perm_r, &dense[k], &Glu)) != 0) { + if ( iperm_r_allocated ) SUPERLU_FREE (iperm_r); + SUPERLU_FREE (iperm_c); + SUPERLU_FREE (relax_end); + return; + } if ( (*info = spivotL(jj, diag_pivot_thresh, &usepr, perm_r, iperm_r, iperm_c, &pivrow, &Glu, stat)) ) @@ -429,5 +451,4 @@ sgstrf (superlu_options_t *options, SuperMatrix *A, if ( iperm_r_allocated ) SUPERLU_FREE (iperm_r); SUPERLU_FREE (iperm_c); SUPERLU_FREE (relax_end); - } -- cgit v1.2.3