Module: wine
Branch: master
Commit: 01111b941d469cb13ed9d3f63c2935930679bcb8
URL: https://source.winehq.org/git/wine.git/?a=commit;h=01111b941d469cb13ed9d3f6…
Author: Eric Pouech <eric.pouech(a)gmail.com>
Date: Thu Dec 16 19:06:48 2021 +0100
msvcrt: Fix double-free and memory leak in type_info destructor.
Spotted by toying with the gcc's static analyzer.
Signed-off-by: Eric Pouech <eric.pouech(a)gmail.com>
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/msvcp90/cxx.h | 2 +-
dlls/msvcrt/cxx.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcp90/cxx.h b/dlls/msvcp90/cxx.h
index 29854d16bab..701ab02fc05 100644
--- a/dlls/msvcp90/cxx.h
+++ b/dlls/msvcp90/cxx.h
@@ -457,7 +457,7 @@ void * __thiscall type_info_vector_dtor(type_info * _this, unsigned int flags) \
/* we have an array, with the number of elements stored before the first object */ \
INT_PTR i, *ptr = (INT_PTR *)_this - 1; \
\
- for (i = *ptr - 1; i >= 0; i--) free(_this->name); \
+ for (i = *ptr - 1; i >= 0; i--) free(_this[i].name); \
free(ptr); \
} \
else \
diff --git a/dlls/msvcrt/cxx.h b/dlls/msvcrt/cxx.h
index 1a5442725ef..cacbb1524b6 100644
--- a/dlls/msvcrt/cxx.h
+++ b/dlls/msvcrt/cxx.h
@@ -291,7 +291,7 @@ void * __thiscall type_info_vector_dtor(type_info * _this, unsigned int flags) \
/* we have an array, with the number of elements stored before the first object */ \
INT_PTR i, *ptr = (INT_PTR *)_this - 1; \
\
- for (i = *ptr - 1; i >= 0; i--) free(_this->name); \
+ for (i = *ptr - 1; i >= 0; i--) free(_this[i].name); \
free(ptr); \
} \
else \