Fix a crash when using sqliteCreateFunction

The segfault is reproduced by the test.
Without this fix, drupal 7 when configured to use sqlite is unusable.
The crash occurs for instance when clearing the cache.