Fixed #389: Providing negative value to memory allocation function.

This PR is based on the patch, provided in ticket #389. I cleaned up the patch, because it did not apply anymore. Furthermore, the new[]-operator was not supported and i rephrased the error message slightly.

Thanks for consider pulling and best regards

Martin Ettl