Fixed length-multiplied malloc checks, added a missing malloc check.
Added and used malloc_mul.