fix a potential null pointer reference in strdup (as found by Patrick Georgi)