Fixes for potential segfaults in atoi().

atoi() is causing a segfault when passed a NULL char pointer.  This
commit fixes a couple places where that could potentially happen as
well as adds in some error responses to the caller in these cases.