What if length == 0? In that case data == NULL would be legal, right? Because you'd never actually dereference the pointer.