]> granicus.if.org Git - php/commitdiff
Fix readlink related memory leak
authorChristoph M. Becker <cmbecker69@gmx.de>
Wed, 15 Jul 2020 15:28:24 +0000 (17:28 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Thu, 16 Jul 2020 07:16:48 +0000 (09:16 +0200)
win32/ioutil.h

index 93dea15967223fac0aea211c3be2cebf98c4d853..05ed3621d2b40229f84aab656178537c7044dacf 100644 (file)
@@ -789,12 +789,14 @@ __forceinline static ssize_t php_win32_ioutil_readlink(const char *path, char *b
 
        ret_buf = php_win32_ioutil_conv_w_to_any(retw, ret, &ret_buf_len);
        if (!ret_buf || ret_buf_len >= buf_len || ret_buf_len >= MAXPATHLEN) {
+               free(ret_buf);
                free(pathw);
                SET_ERRNO_FROM_WIN32_CODE(ERROR_BAD_PATHNAME);
                return -1;
        }
        memcpy(buf, ret_buf, ret_buf_len + 1);
 
+       free(ret_buf);
        free(pathw);
 
        return ret_buf_len;