An unsafe use of unsafePackCStringLen

The use of unsafePackCStringLen was unsafe because nothing
prevented the pcre object from garbage collected.

With this patch, I no longer see 'out of memory' errors. However with my test case, 'out of memory' also goes away when I make a small unrelated change like adding a print statement. So I'm not 100% sure that this commit fixes the issue.