Replace strdup() with M_StringDuplicate().

strdup() can theoretically fail and return NULL. This could lead to
a crash or undesirable behavior. Add M_StringDuplicate() which does
the same thing but exits with an error if a string cannot be
allocated.

This fixes #456. Thanks to Quasar for the suggestion.