Marcus Meissner : msvcrt: read_utf8: free readbuf on return (Coverity).

Alexandre Julliard julliard at winehq.org
Mon Jan 21 13:52:23 CST 2013


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

Author: Marcus Meissner <marcus at jet.franken.de>
Date:   Sun Jan 20 13:17:09 2013 +0100

msvcrt: read_utf8: free readbuf on return (Coverity).

---

 dlls/msvcrt/file.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 0df6a86..8a63b51 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -2226,13 +2226,16 @@ static int read_utf8(int fd, MSVCRT_wchar_t *buf, unsigned int count)
             num_read = 0;
         }else if(GetLastError() == ERROR_BROKEN_PIPE) {
             fdinfo->wxflag |= WX_ATEOF;
+            if (readbuf != min_buf) MSVCRT_free(readbuf);
             return 0;
         }else {
             msvcrt_set_errno(GetLastError());
+            if (readbuf != min_buf) MSVCRT_free(readbuf);
             return -1;
         }
     }else if(!pos && !num_read) {
         fdinfo->wxflag |= WX_ATEOF;
+        if (readbuf != min_buf) MSVCRT_free(readbuf);
         return 0;
     }
 
@@ -2291,9 +2294,11 @@ static int read_utf8(int fd, MSVCRT_wchar_t *buf, unsigned int count)
 
     if(!(num_read = MultiByteToWideChar(CP_UTF8, 0, readbuf, pos, buf, count))) {
         msvcrt_set_errno(GetLastError());
+        if (readbuf != min_buf) MSVCRT_free(readbuf);
         return -1;
     }
 
+    if (readbuf != min_buf) MSVCRT_free(readbuf);
     return num_read*2;
 }
 




More information about the wine-cvs mailing list