PIM-3556: Fix memory leak on versionning

That's half of the correction of memory leak