Mercurial > octave
changeset 26163:d478d5d1c8e9
Fix potential segfault on Windows.
* lo-sysdep.cc (get_dirlist): Fix potential segfault with FormatMessageA. Use
C++ syntax.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Mon, 03 Dec 2018 19:32:31 +0100 |
parents | ef1ef6364a6a |
children | 7f6a50f73625 |
files | liboctave/system/lo-sysdep.cc |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/system/lo-sysdep.cc Mon Dec 03 19:15:06 2018 +0100 +++ b/liboctave/system/lo-sysdep.cc Mon Dec 03 19:32:31 2018 +0100 @@ -102,14 +102,14 @@ if (INVALID_HANDLE_VALUE == hFind) { DWORD errCode = GetLastError (); - char *errorText; + char *errorText = nullptr; FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, errCode, + nullptr, errCode, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - errorText, 0, NULL); - if (errorText != NULL) + reinterpret_cast <char *> (&errorText), 0, nullptr); + if (errorText != nullptr) { msg = std::string (errorText); LocalFree (errorText);