Fix some memory leaks

fix http://hub.qgis.org/issues/6795