v.20.4Bug Fix

Fixed Array Size Overflow in generateRandom Function

Fixed potential array size overflow in generateRandom that may lead to crash. This fixes #11371. #12013 (alexey-milovidov).