the assert should happen before, i.e. this should become
char * key;
assert(...)
key = apr_psprintf(...)