Fixes empty buffer crash.