Pull up revision 1.31, requested by maxv in #1209:

Prevent a user-triggerable kmem_alloc(0).
Ticket #1209