fix segmentation fault on Mac OS X