Blame SOURCES/jasper-1.900.1-Coverity-RESOURCE_LEAK.patch

83be9e
Error: RESOURCE_LEAK
83be9e
src/appl/imgcmp.c:504: var_assign: Assigning: "diffimage" =  storage returned from "jas_image_create(3, compparms, 1025)".
83be9e
src/appl/imgcmp.c:511: leaked_storage: Variable "diffimage" going out of scope leaks the storage it points to.
83be9e
src/appl/imgcmp.c:537: leaked_storage: Variable "diffimage" going out of scope leaks the storage it points to.
83be9e
83be9e
base/jas_image.c:254: var_assign: Assigning: "newcmpt" =  storage returned from "jas_image_cmpt_create0()".
83be9e
base/jas_image.c:268: leaked_storage: Variable "newcmpt" going out of scope leaks the storage it points to.
83be9e
base/jas_image.c:271: leaked_storage: Variable "newcmpt" going out of scope leaks the storage it points to.
83be9e
base/jas_image.c:274: leaked_storage: Variable "newcmpt" going out of scope leaks the storage it points to.
83be9e
base/jas_image.c:277: leaked_storage: Variable "newcmpt" going out of scope leaks the storage it points to.
83be9e
83be9e
base/jas_cm.c:611: var_assign: Assigning: "newpxformseq" =  storage returned from "jas_cmpxformseq_create()".
83be9e
base/jas_cm.c:617: leaked_storage: Variable "newpxformseq" going out of scope leaks the storage it points to.
83be9e
83be9e
base/jas_cm.c:343: var_assign: Assigning: "newprof" =  storage returned from "jas_cmprof_create()".
83be9e
base/jas_cm.c:358: leaked_storage: Variable "newprof" going out of scope leaks the storage it points to.
83be9e
83be9e
base/jas_cm.c:380: var_assign: Assigning: "xform" =  storage returned from "jas_malloc(sizeof (jas_cmxform_t) /*16*/)".
83be9e
base/jas_cm.c:461: leaked_storage: Variable "xform" going out of scope leaks the storage it points to.
83be9e
83be9e
base/jas_image.c:1379: var_assign: Assigning: "xform" =  storage returned from "jas_cmxform_create(inprof, outprof, NULL, 0, intent, 0)".
83be9e
base/jas_image.c:1444: leaked_storage: Variable "xform" going out of scope leaks the storage it points to.
83be9e
83be9e
base/jas_image.c:1306: var_assign: Assigning: "inimage" =  storage returned from "jas_image_copy(image)".
83be9e
base/jas_image.c:1444: leaked_storage: Variable "inimage" going out of scope leaks the storage it points to.
83be9e
83be9e
base/jas_image.c:1345: var_assign: Assigning: "outimage" =  storage returned from "jas_image_create0()".
83be9e
base/jas_image.c:1444: leaked_storage: Variable "outimage" going out of scope leaks the storage it points to.
83be9e
83be9e
bmp/bmp_enc.c:187: var_assign: Assigning: "info" =  storage returned from "bmp_info_create()".
83be9e
bmp/bmp_enc.c:208: leaked_storage: Variable "info" going out of scope leaks the storage it points to.
83be9e
83be9e
jpc/jpc_tagtree.c:111: var_assign: Assigning: "tree" =  storage returned from "jpc_tagtree_alloc()".
83be9e
jpc/jpc_tagtree.c:129: leaked_storage: Variable "tree" going out of scope leaks the storage it points to.
83be9e
83be9e
jpc/jpc_dec.c:452: var_assign: Assigning: "compinfos" =  storage returned from "jas_malloc(dec->numcomps * sizeof (jas_image_cmptparm_t) /*56*/)".
83be9e
jpc/jpc_dec.c:468: leaked_storage: Variable "compinfos" going out of scope leaks the storage it points to.
83be9e
83be9e
jpc/jpc_dec.c:1483: var_assign: Assigning: "cp" =  storage returned from "jas_malloc(sizeof (jpc_dec_cp_t) /*48*/)".
83be9e
jpc/jpc_dec.c:1493: leaked_storage: Variable "cp" going out of scope leaks the storage it points to.
83be9e
jpc/jpc_dec.c:1497: leaked_storage: Variable "cp" going out of scope leaks the storage it points to.
83be9e
83be9e
mif/mif_cod.c:523: var_assign: Assigning: "cmpt" =  storage returned from "mif_cmpt_create()".
83be9e
mif/mif_cod.c:568: leaked_storage: Variable "cmpt" going out of scope leaks the storage it points to.
83be9e
83be9e
mif/mif_cod.c:568: leaked_storage: Variable "tvp" going out of scope leaks the storage it points to.
83be9e
83be9e
83be9e
diff -up jasper-1.900.1/src/appl/imgcmp.c.RESOURCE_LEAK jasper-1.900.1/src/appl/imgcmp.c
83be9e
--- jasper-1.900.1/src/appl/imgcmp.c.RESOURCE_LEAK	2007-01-19 22:43:08.000000000 +0100
83be9e
+++ jasper-1.900.1/src/appl/imgcmp.c	2011-12-08 14:16:04.727027007 +0100
83be9e
@@ -507,6 +507,7 @@ jas_image_t *makediffimage(jas_matrix_t
83be9e
 
83be9e
 	for (i = 0; i < 3; ++i) {
83be9e
 		if (!(diffdata[i] = jas_matrix_create(height, width))) {
83be9e
+			jas_image_destroy(diffimage);
83be9e
 			fprintf(stderr, "internal error\n");
83be9e
 			return 0;
83be9e
 		}
83be9e
@@ -534,6 +535,7 @@ jas_image_t *makediffimage(jas_matrix_t
83be9e
 
83be9e
 	for (i = 0; i < 3; ++i) {
83be9e
 		if (jas_image_writecmpt(diffimage, i, 0, 0, width, height, diffdata[i])) {
83be9e
+			jas_image_destroy(diffimage);
83be9e
 			return 0;
83be9e
 		}
83be9e
 	}
83be9e
diff -up jasper-1.900.1/src/libjasper/base/jas_cm.c.RESOURCE_LEAK jasper-1.900.1/src/libjasper/base/jas_cm.c
83be9e
--- jasper-1.900.1/src/libjasper/base/jas_cm.c.RESOURCE_LEAK	2011-12-08 14:16:03.387043758 +0100
83be9e
+++ jasper-1.900.1/src/libjasper/base/jas_cm.c	2011-12-08 14:16:04.728026994 +0100
83be9e
@@ -355,6 +355,8 @@ jas_cmprof_t *jas_cmprof_copy(jas_cmprof
83be9e
 	}
83be9e
 	return newprof;
83be9e
 error:
83be9e
+	if (newprof)
83be9e
+		jas_cmprof_destroy(newprof);
83be9e
 	return 0;
83be9e
 }
83be9e
 
83be9e
@@ -458,6 +460,8 @@ jas_cmxform_t *jas_cmxform_create(jas_cm
83be9e
 	}
83be9e
 	return xform;
83be9e
 error:
83be9e
+	if (xform)
83be9e
+		jas_cmxform_destroy(xform);
83be9e
 	return 0;
83be9e
 }
83be9e
 
83be9e
@@ -614,6 +618,8 @@ static jas_cmpxformseq_t *jas_cmpxformse
83be9e
 		goto error;
83be9e
 	return newpxformseq;
83be9e
 error:
83be9e
+	if (newpxformseq)
83be9e
+		jas_cmpxformseq_destroy(newpxformseq);
83be9e
 	return 0;
83be9e
 }
83be9e
 
83be9e
diff -up jasper-1.900.1/src/libjasper/base/jas_image.c.RESOURCE_LEAK jasper-1.900.1/src/libjasper/base/jas_image.c
83be9e
--- jasper-1.900.1/src/libjasper/base/jas_image.c.RESOURCE_LEAK	2011-12-08 14:16:04.635028156 +0100
83be9e
+++ jasper-1.900.1/src/libjasper/base/jas_image.c	2011-12-08 14:16:04.776026394 +0100
83be9e
@@ -268,15 +268,19 @@ static jas_image_cmpt_t *jas_image_cmpt_
83be9e
 	newcmpt->cps_ = cmpt->cps_;
83be9e
 	newcmpt->type_ = cmpt->type_;
83be9e
 	if (!(newcmpt->stream_ = jas_stream_memopen(0, 0))) {
83be9e
+		jas_image_cmpt_destroy(newcmpt);
83be9e
 		return 0;
83be9e
 	}
83be9e
 	if (jas_stream_seek(cmpt->stream_, 0, SEEK_SET)) {
83be9e
+		jas_image_cmpt_destroy(newcmpt);
83be9e
 		return 0;
83be9e
 	}
83be9e
 	if (jas_stream_copy(newcmpt->stream_, cmpt->stream_, -1)) {
83be9e
+		jas_image_cmpt_destroy(newcmpt);
83be9e
 		return 0;
83be9e
 	}
83be9e
 	if (jas_stream_seek(newcmpt->stream_, 0, SEEK_SET)) {
83be9e
+		jas_image_cmpt_destroy(newcmpt);
83be9e
 		return 0;
83be9e
 	}
83be9e
 	return newcmpt;
83be9e
@@ -1443,5 +1447,11 @@ jas_image_dump(outimage, stderr);
83be9e
 #endif
83be9e
 	return outimage;
83be9e
 error:
83be9e
+	if (xform)
83be9e
+		jas_cmxform_destroy(xform);
83be9e
+	if (inimage)
83be9e
+		jas_image_destroy(inimage);
83be9e
+	if (outimage)
83be9e
+		jas_image_destroy(outimage);
83be9e
 	return 0;
83be9e
 }
83be9e
diff -up jasper-1.900.1/src/libjasper/bmp/bmp_enc.c.RESOURCE_LEAK jasper-1.900.1/src/libjasper/bmp/bmp_enc.c
83be9e
--- jasper-1.900.1/src/libjasper/bmp/bmp_enc.c.RESOURCE_LEAK	2007-01-19 22:43:07.000000000 +0100
83be9e
+++ jasper-1.900.1/src/libjasper/bmp/bmp_enc.c	2011-12-08 14:16:04.826025768 +0100
83be9e
@@ -205,16 +205,19 @@ int bmp_encode(jas_image_t *image, jas_s
83be9e
 
83be9e
 	/* Write the bitmap header. */
83be9e
 	if (bmp_puthdr(out, &hdr)) {
83be9e
+		bmp_info_destroy(info);
83be9e
 		return -1;
83be9e
 	}
83be9e
 
83be9e
 	/* Write the bitmap information. */
83be9e
 	if (bmp_putinfo(out, info)) {
83be9e
+		bmp_info_destroy(info);
83be9e
 		return -1;
83be9e
 	}
83be9e
 
83be9e
 	/* Write the bitmap data. */
83be9e
 	if (bmp_putdata(out, info, image, enc->cmpts)) {
83be9e
+		bmp_info_destroy(info);
83be9e
 		return -1;
83be9e
 	}
83be9e
 
83be9e
diff -up jasper-1.900.1/src/libjasper/jpc/jpc_dec.c.RESOURCE_LEAK jasper-1.900.1/src/libjasper/jpc/jpc_dec.c
83be9e
--- jasper-1.900.1/src/libjasper/jpc/jpc_dec.c.RESOURCE_LEAK	2011-12-08 14:16:04.594028668 +0100
83be9e
+++ jasper-1.900.1/src/libjasper/jpc/jpc_dec.c	2011-12-08 14:17:25.677014992 +0100
83be9e
@@ -465,6 +465,7 @@ static int jpc_dec_process_sot(jpc_dec_t
83be9e
 
83be9e
 		if (!(dec->image = jas_image_create(dec->numcomps, compinfos,
83be9e
 		  JAS_CLRSPC_UNKNOWN))) {
83be9e
+			jas_free(compinfos);
83be9e
 			return -1;
83be9e
 		}
83be9e
 		jas_free(compinfos);
83be9e
@@ -1490,10 +1491,11 @@ static jpc_dec_cp_t *jpc_dec_cp_create(u
83be9e
 	cp->mctid = 0;
83be9e
 	cp->csty = 0;
83be9e
 	if (!(cp->ccps = jas_alloc2(cp->numcomps, sizeof(jpc_dec_ccp_t)))) {
83be9e
+		jpc_dec_cp_destroy(cp);
83be9e
 		return 0;
83be9e
 	}
83be9e
 	if (!(cp->pchglist = jpc_pchglist_create())) {
83be9e
-		jas_free(cp->ccps);
83be9e
+		jpc_dec_cp_destroy(cp);
83be9e
 		return 0;
83be9e
 	}
83be9e
 	for (compno = 0, ccp = cp->ccps; compno < cp->numcomps;
83be9e
diff -up jasper-1.900.1/src/libjasper/jpc/jpc_tagtree.c.RESOURCE_LEAK jasper-1.900.1/src/libjasper/jpc/jpc_tagtree.c
83be9e
--- jasper-1.900.1/src/libjasper/jpc/jpc_tagtree.c.RESOURCE_LEAK	2011-12-08 14:16:04.000000000 +0100
83be9e
+++ jasper-1.900.1/src/libjasper/jpc/jpc_tagtree.c	2011-12-08 14:17:55.905637082 +0100
83be9e
@@ -126,6 +126,7 @@ jpc_tagtree_t *jpc_tagtree_create(int nu
83be9e
 	} while (n > 1);
83be9e
 
83be9e
 	if (!(tree->nodes_ = jas_alloc2(tree->numnodes_, sizeof(jpc_tagtreenode_t)))) {
83be9e
+		jpc_tagtree_destroy(tree);
83be9e
 		return 0;
83be9e
 	}
83be9e
 
83be9e
diff -up jasper-1.900.1/src/libjasper/mif/mif_cod.c.RESOURCE_LEAK jasper-1.900.1/src/libjasper/mif/mif_cod.c
83be9e
--- jasper-1.900.1/src/libjasper/mif/mif_cod.c.RESOURCE_LEAK	2011-12-08 14:16:04.250032970 +0100
83be9e
+++ jasper-1.900.1/src/libjasper/mif/mif_cod.c	2011-12-08 14:16:04.967024005 +0100
83be9e
@@ -564,7 +564,7 @@ static int mif_process_cmpt(mif_hdr_t *h
83be9e
 			break;
83be9e
 		case MIF_DATA:
83be9e
 			if (!(cmpt->data = jas_strdup(jas_tvparser_getval(tvp)))) {
83be9e
-				return -1;
83be9e
+				goto error;
83be9e
 			}
83be9e
 			break;
83be9e
 		}