]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix, actually consume data between calls to _warc_read()
authorSebastian Freundt <freundt@ga-group.nl>
Wed, 21 May 2014 15:18:41 +0000 (15:18 +0000)
committerSebastian Freundt <freundt@ga-group.nl>
Wed, 21 May 2014 15:18:52 +0000 (15:18 +0000)
libarchive/archive_read_support_format_warc.c

index d138a35496e5ec2e10f7d961a49f4ef7254a08b6..926847bb7b6ddb61bb2efce5b97e5952b6b06a45 100644 (file)
@@ -87,6 +87,8 @@ struct warc_s {
        size_t cntlen;
        /* and how much we've processed so far */
        size_t cntoff;
+       /* and how much we need to consume between calls */
+       size_t unconsumed;
 
        /* string pool */
        warc_strbuf_t pool;
@@ -297,6 +299,11 @@ _warc_read(struct archive_read *a, const void **buf, size_t *bsz, int64_t *off)
        const char *rab;
        ssize_t nrd;
 
+       if (w->unconsumed) {
+               __archive_read_consume(a, w->unconsumed);
+               w->unconsumed = 0U;
+       }
+
        if (w->cntoff >= w->cntlen) {
        eof:
                /* it's our lucky day, no work, we can leave early */
@@ -322,6 +329,7 @@ _warc_read(struct archive_read *a, const void **buf, size_t *bsz, int64_t *off)
        *buf = rab;
 
        w->cntoff += nrd;
+       w->unconsumed = (size_t)nrd;
        return (ARCHIVE_OK);
 }