From f6a62ecad106821a517fbdb07d31a8d825fffb64 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 11 Sep 2014 00:07:23 -0400 Subject: [PATCH] Make sure read buffers get reinitialized before refilling (thanks, Michael!). --- docs/CREDITS.txt | 3 +++ src/physfs.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/CREDITS.txt b/docs/CREDITS.txt index 514b3678..f28d6b21 100644 --- a/docs/CREDITS.txt +++ b/docs/CREDITS.txt @@ -139,6 +139,9 @@ Bug fixes: Bug fixes: Andreas Karlsson +Bug fixes: + Michael Bacon + pkg-config support: Jonas Kulla diff --git a/src/physfs.c b/src/physfs.c index 2a6bb496..be0b9f4c 100644 --- a/src/physfs.c +++ b/src/physfs.c @@ -2556,20 +2556,21 @@ static PHYSFS_sint64 doBufferedRead(FileHandle *fh, void *buffer, memcpy(buffer, fh->buffer + fh->bufpos, (size_t) len); fh->bufpos += (PHYSFS_uint32) len; return (PHYSFS_sint64) len; - } /* else if */ + } /* if */ - if (buffered > 0) /* partially in the buffer... */ + else if (buffered > 0) /* partially in the buffer... */ { memcpy(buffer, fh->buffer + fh->bufpos, (size_t) buffered); buffer = ((PHYSFS_uint8 *) buffer) + buffered; len -= buffered; retval = buffered; - fh->buffill = fh->bufpos = 0; } /* if */ /* if you got here, the buffer is drained and we still need bytes. */ assert(len > 0); + fh->buffill = fh->bufpos = 0; + io = fh->io; if (len >= fh->bufsize) /* need more than the buffer takes. */ {