It won't crash just because a font with the given number doesn't exist - it will just return nullptr.
You should test that modelRef is non-null. GetFontByNumber(fontNum, modelRef) is just going to call GetFontByNumber(fontNum, modelRef->GetDgnFileP()), which will obviously produce an access violation if modelRef is nullptr.
You should test that modelRef is non-null. GetFontByNumber(fontNum, modelRef) is just going to call GetFontByNumber(fontNum, modelRef->GetDgnFileP()), which will obviously produce an access violation if modelRef is nullptr.