summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorppatience0 <ppatience0@gmail.com>2013-06-01 17:14:50 -0400
committerppatience0 <ppatience0@gmail.com>2013-06-01 17:14:50 -0400
commit74416281b0a13735bcbde178fc084fbe80b1a33e (patch)
treeaf3867b94615cadc26dbbc744b804ef3bc24fcba
parent6c4d8f8b11bf04959c920c0720a60949db038a65 (diff)
downloadplan9front-74416281b0a13735bcbde178fc084fbe80b1a33e.tar.xz
readgif, readjpg: fix incorrect malloc arguments: use sizeof(Rawimage*) instead of sizeof(Rawimage**) and 2*sizeof(Rawimage*) instead of sizeof(Header)
readtga: switch calloc arguments: nelem is supposed to first, elsize second
-rw-r--r--sys/src/cmd/jpg/readgif.c2
-rw-r--r--sys/src/cmd/jpg/readjpg.c2
-rw-r--r--sys/src/cmd/jpg/readtga.c4
3 files changed, 4 insertions, 4 deletions
diff --git a/sys/src/cmd/jpg/readgif.c b/sys/src/cmd/jpg/readgif.c
index 3521753fd..0a5edd364 100644
--- a/sys/src/cmd/jpg/readgif.c
+++ b/sys/src/cmd/jpg/readgif.c
@@ -156,7 +156,7 @@ readarray(Header *h)
if(h->fields & 0x80)
h->globalcmap = readcmap(h, (h->fields&7)+1);
- array = malloc(sizeof(Rawimage**));
+ array = malloc(sizeof(Rawimage*));
if(array == nil)
giferror(h, memerr);
nimages = 0;
diff --git a/sys/src/cmd/jpg/readjpg.c b/sys/src/cmd/jpg/readjpg.c
index c50260e5d..a3ab3ed8a 100644
--- a/sys/src/cmd/jpg/readjpg.c
+++ b/sys/src/cmd/jpg/readjpg.c
@@ -247,7 +247,7 @@ Breadjpg(Biobuf *b, int colorspace)
}
jpginit();
h = malloc(sizeof(Header));
- array = malloc(sizeof(Header));
+ array = malloc(2*sizeof(Rawimage*));
if(h==nil || array==nil){
free(h);
free(array);
diff --git a/sys/src/cmd/jpg/readtga.c b/sys/src/cmd/jpg/readtga.c
index afea0fad0..b0ba260d3 100644
--- a/sys/src/cmd/jpg/readtga.c
+++ b/sys/src/cmd/jpg/readtga.c
@@ -404,12 +404,12 @@ Breadtga(Biobuf *bp)
}
array = nil;
- if((ar = calloc(sizeof(Rawimage), 1)) == nil){
+ if((ar = calloc(1, sizeof(Rawimage))) == nil){
werrstr("ReadTGA: no memory - %r\n");
goto Error;
}
- if((array = calloc(sizeof(Rawimage *), 2)) == nil){
+ if((array = calloc(2, sizeof(Rawimage *))) == nil){
werrstr("ReadTGA: no memory - %r\n");
goto Error;
}