__mingw_wcstof() dereferencing of NULL pointer fixed
(cherry picked from commit 051971a34bf187e202843df485c1106abd44b3dc)
diff --git a/mingw-w64-crt/misc/mingw_wcstof.c b/mingw-w64-crt/misc/mingw_wcstof.c
index a19862a..01f0da0 100644
--- a/mingw-w64-crt/misc/mingw_wcstof.c
+++ b/mingw-w64-crt/misc/mingw_wcstof.c
@@ -18,14 +18,13 @@
r = __mingw_strtof (n, &ep);
if (ep != NULL)
{
- *ep = 0;
l2 = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, n, -1, NULL, 0);
if (l2 > 0)
l2 -= 1; /* Remove zero terminator from length. */
- *_EndPtr = (wchar_t *) &_Str[l2];
+ if (_EndPtr) *_EndPtr = (wchar_t *) &_Str[l2];
}
else
- *_EndPtr = NULL;
+ if (_EndPtr) *_EndPtr = NULL;
return r;
}