fixed issue 2413: sg_malloc in graph cut

This is  for #2413.