MS-WSP: Don't allocate huge amounts of memory.
Add a couple of memory allocation sanity checks, one of which fixes #17331 (closed).
(cherry picked from commit b7a0650e)
Add a couple of memory allocation sanity checks, one of which fixes #17331 (closed).
(cherry picked from commit b7a0650e)