Guard against bogus values of ph.width, ph.height and document why there are no allocation overflows. (cherry picked from commit 5aa82f3b)