Fix infinite recursion in agg when drawing bezier with invalid points

* Patch extracted from http://trac.osgeo.org/mapserver/ticket/3862
* Fixes #6738