Patch for zero length malloc and check for malloc success

There is a feasible code path such that the string will
have a length of zero.  Malloc of a zero length has a
implementation dependent result (i.e. possible invalid
memory pointer).  Add one to the requested length to
eliminate the abiguity.  In addition, check the return
from malloc to insure it was successful.