Fixed MaybeDangling validation logic

Corrected a bug in the validation logic for MaybeDangling references that was incorrectly rejecting valid pointers at extreme addresses, and added regression tests to prevent similar issues in the future.