Piotr Caban : msvcrt: Handle negative file->_cnt value in fwrite.

Alexandre Julliard julliard at winehq.org
Wed Jun 11 13:36:25 CDT 2014


Module: wine
Branch: master
Commit: b0424313fd16efea4a08732f4ed530df30d350cd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b0424313fd16efea4a08732f4ed530df30d350cd

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Mon Jun  9 14:24:14 2014 +0200

msvcrt: Handle negative file->_cnt value in fwrite.

---

 dlls/msvcrt/file.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 77a0fed..7ebf6d2 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -3691,7 +3691,11 @@ MSVCRT_size_t CDECL MSVCRT_fwrite(const void *ptr, MSVCRT_size_t size, MSVCRT_si
     MSVCRT__lock_file(file);
 
     while(wrcnt) {
-        if(file->_cnt) {
+        if(file->_cnt < 0) {
+            WARN("negative file->_cnt value in %p\n", file);
+            file->_flag |= MSVCRT__IOERR;
+            break;
+        } else if(file->_cnt) {
             int pcnt=(file->_cnt>wrcnt)? wrcnt: file->_cnt;
             memcpy(file->_ptr, ptr, pcnt);
             file->_cnt -= pcnt;




More information about the wine-cvs mailing list