Fixed invalid free, discovered by scan-build