Fix null deref (thx @hugsy)

A return value from get_bek_dataset() wasn't checked before using an
output parameter.