Bugfix: prevent ouf-of-bounds exception when searching for a common
prefix