switch_mprintf -> asprintf, note this changes behaviour somewhat.

Also test for null before dereference.

switch_mprintf supports %q which literal prints escaped characters,
I'm testing behaviour with %s which will escape characters as per
normal.