mongodb: fix shell crash for stable with clang.

Closes #24805.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>