strndup.c: Handle malloc failures

Closes #2
Merge pull request #4 from clibs/fix/gh-2-malloc-failures

strndup.c: Handle malloc failures