v.20.3Bug Fix

Fixed array size overflow in generateRandom to prevent crashes

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