Sorry, it's not a bug. ogg_sync_destroy frees the_ogg_sync_state, which you didn't malloc. You want ogg_sync_clear() to just free the internal storage. -r