Quoth adr via 9fans <9fans@9fans.net>:
> Checking the sent mail I noticed that I forgot to remove mag...

Why not make getchunk allocate? Somethign like:

--- 
//.git/fs/object/e8259861da3a55c03491904e4d11c5c15b7577c5/tree/sys/src/cmd/jpg/readpng.c
+++ sys/src/cmd/jpg/readpng.c
@@ -94,7 +94,7 @@
 }
 
 static int
-getchunk(Biobuf *b, char *type, uchar *d, int m)
+getchunk(Biobuf *b, char *type, uchar **d)
 {
        uchar buf[8];
        ulong crc = 0, crc2;
@@ -103,11 +103,10 @@
        if(Bread(b, buf, 8) != 8)
                return -1;
        n = get4(buf);
+       *d = pngmalloc(n, 0);
        memmove(type, buf+4, 4);
        type[4] = 0;
-       if(n > m)
-               sysfatal("getchunk needed %d, had %d", n, m);
-       nr = Bread(b, d, n);
+       nr = Bread(b, *d, n);
        if(nr != n)
                sysfatal("getchunk read %d, expected %d", nr, n);
        crc = blockcrc(crctab, crc, type, 4);
@@ -131,7 +130,7 @@
        Again:
                z->p = z->buf;
                z->e = z->p;
-               n = getchunk(z->io, type, z->p, IDATSIZE);
+               n = getchunk(z->io, type, &z->p);
                if(n < 0 || strcmp(type, "IEND") == 0)
                        return -1;
                z->e = z->p + n;


------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T4a714ed14c50767a-Md2aafc19d425830aec9c5ea9
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to