Fix for CVE-2012-0722, patch provided by Sajjad Pourali

Fix for issue #67