Fix a CPU and memory leak.

Hello, the following changed i have made will fix a massive CPU and memory leak. This was crashing our server non-stop for 2 days.