strndup.c: Handle malloc failures

Closes #2