More bugs found thanks to klockwork
authorKent Mein <mein@cs.umn.edu>
Fri, 27 Oct 2006 15:00:31 +0000 (15:00 +0000)
committerKent Mein <mein@cs.umn.edu>
Fri, 27 Oct 2006 15:00:31 +0000 (15:00 +0000)
mallocn.c  check malloced memory before using it.
ssp_blas2.c free memory that wasn't but should have been.

Kent

intern/guardedalloc/intern/mallocn.c
intern/opennl/superlu/ssp_blas2.c

index 03a3a786df2176368bf5bb61387021ab78837ba8..77184ac9370d0ca5249de3e69152c90c17213df8 100644 (file)
@@ -210,6 +210,9 @@ void *MEM_dupallocN(void *vmemh)
                        newp= MEM_mapallocN(memh->len, "dupli_mapalloc");
                else
                        newp= MEM_mallocN(memh->len, "dupli_alloc");
+
+               if (newp == NULL) return NULL;
+
                memcpy(newp, vmemh, memh->len);
        }
 
index 347f9ab5fd4176a7e6a02ac124b00c068430f714..e9f8f53128a9f413e2c5106ae1912e0e3ffbafc2 100644 (file)
@@ -119,7 +119,10 @@ sp_strsv(char *uplo, char *trans, char *diag, SuperMatrix *L,
        
        if ( lsame_(uplo, "L") ) {
            /* Form x := inv(L)*x */
-           if ( L->nrow == 0 ) return 0; /* Quick return */
+           if ( L->nrow == 0 ) {
+                       SUPERLU_FREE(work);
+                       return 0; /* Quick return */
+               }
            
            for (k = 0; k <= Lstore->nsuper; k++) {
                fsupc = L_FST_SUPC(k);