d2d: fix crash if an invalid frame comes