ticket module: Fixing potential memleaks