Check scalar->d before we use it (in BN_num_bits()). (Coverity ID 129)