From 1b45536fe26869b452d9abe6292d0f682454c8a0 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 16 Jan 2014 19:54:19 +0900 Subject: [PATCH] [bugfix] ungetc enters infinite loop --- src/port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/port.c b/src/port.c index 14a94c90..2c8c636a 100644 --- a/src/port.c +++ b/src/port.c @@ -177,7 +177,7 @@ pic_fread(void *ptr, size_t block, size_t nitems, pic_file *file) /* take care of ungetc buf */ while (file->ur > 0) { *dst++ = file->ub[--file->ur]; - if (size == 0) + if (--size == 0) return block * nitems; }