On failure, I suppose pcre_compile() returns an error string in errorstr; if it does that in a static buffer, this code is OK; but, if it allocates the error string and you're expected to free() it, you're leaking it here.