summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-05-29 17:53:49 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-05-29 17:53:49 +0200
commitd3243530d709296231a6e29d9047c5692c5fddc3 (patch)
tree4a3e8e0d7f8dde299b99b3d10b14b0d8f7e33c62
parent845db4c37263c473bde38b23349a33202d92d066 (diff)
downloadplan9front-d3243530d709296231a6e29d9047c5692c5fddc3.tar.xz
jpg: fix memory corruption
-rw-r--r--sys/src/cmd/jpg/readjpg.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/src/cmd/jpg/readjpg.c b/sys/src/cmd/jpg/readjpg.c
index 8653d72d2..ddc3227f6 100644
--- a/sys/src/cmd/jpg/readjpg.c
+++ b/sys/src/cmd/jpg/readjpg.c
@@ -488,8 +488,10 @@ huffmantable(Header *h, uchar *b)
/* flow chart C-2 */
nsize = 0;
- for(i=0; i<16; i++)
- nsize += b[1+i];
+ for(i=1; i<=16; i++)
+ nsize += b[i];
+ if(nsize == 0)
+ return 0;
t->size = jpgmalloc(h, (nsize+1)*sizeof(int), 1);
k = 0;
for(i=1; i<=16; i++){