could trigger a core dump on some systems.
test/repl/test-multicomp test/repl/test-repl \
test/scan/test-scan test/scan/test-scan-multibyte \
test/sequences/test-flist test/sequences/test-mark \
+ test/sequences/test-out-of-range \
test/slocal/test-slocal \
test/whatnow/test-attach-detach test/whatnow/test-cd \
test/whatnow/test-ls test/whom/test-whom \
* check if message is in-range and exists.
*/
if (mp->msgflags & ALLOW_NEW) {
+ /*
+ * We can get into a case where the "cur" sequence is way out
+ * of range, and because it's allowed to not exist (think
+ * of "rmm; next") it doesn't get checked to make sure it's
+ * within the range of messages in seq_init(). So if our
+ * desired sequence is out of range of the allocated folder
+ * limits simply reallocate the folder so it's within range.
+ */
+ if (first < mp->lowoff || first > mp->hghoff)
+ mp = folder_realloc(mp, first < mp->lowoff ? first : mp->lowoff,
+ first > mp->hghoff ? first : mp->hghoff);
+
set_select_empty (mp, first);
} else {
if (first > mp->hghmsg
--- /dev/null
+#!/bin/sh
+############################################################
+#
+# Test to see if a out-of-range sequence is handled properly
+#
+############################################################
+
+set -e
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
+
+setup_test
+
+cat > $MH_TEST_DIR/Mail/inbox/.mh_sequences <<EOS
+cur: 120
+test: 121
+EOS
+
+run_test 'mhpath +inbox test' 'mhpath: sequence test empty'
+
+cat > $MH_TEST_DIR/Mail/inbox/.mh_sequences <<EOS
+cur: 120
+test: 121
+EOS
+
+#
+# Yes, this is right. "cur" is special in that it can refer to messages
+# that don't exist.
+#
+run_test 'mhpath +inbox cur' "$MH_TEST_DIR/Mail/inbox/120"
+
+exit $failed