Added some initialization for a few variables to fix the issue of intege...

...r overflow when calculating the amount of memory to allocate.

GitHub issue #4180