@@ -257,8 +257,29 @@ msg_base = {
257257 //already have it
258258 console . putmsg ( green + high_intensity + "Go to message #> " ) ;
259259 console . ungetstr ( uchoice ) ; //put it back on the input stack
260- msg_base . dispMsg ( new MsgBase ( bbs . cursub_code ) ,
261- console . getnum ( maxMsgs ) , false ) ;
260+ try {
261+ if ( userSettings . debug . message_scan ) {
262+ console . putmsg ( "Entered dispMsg()'s try/catch\n" ) ;
263+ }
264+ msg_base . dispMsg ( new MsgBase ( bbs . cursub_code ) ,
265+ console . getnum ( base . last_msg ) , false ) ;
266+ //switched out maxMsgs (500) for base.last_msg above. duh
267+ } catch ( e ) {
268+ if ( userSettings . debug . message_scan ) {
269+ console . putmsg ( cyan + "Did we even fuckin get here?" ) ;
270+ }
271+
272+ if ( e . number == 3 ) {
273+ console . putmsg ( yellow + "Invalid message #!\n" ) ;
274+ } else {
275+ console . putmsg ( red +
276+ "Something is not normal here\n" ) ;
277+ throw new docIface . dDocException (
278+ "Numeric read exception" ,
279+ "Unknown error trying to select message to read by"
280+ + " number" , 1 ) ;
281+ }
282+ }
262283 break ;
263284 default :
264285 console . putmsg ( normal + yellow + "Invalid choice\n" ) ;
@@ -623,14 +644,28 @@ msg_base = {
623644 }
624645 }
625646
647+ //let's try and find out if the message we're going to go looking for
648+ //is bogus before we waste time with this, especially since the mHdr
649+ //===null tested block doesn't seem to keep horrible things from
650+ //happening with a ptr passed that's way out of range
651+ if ( ptr < 1 ) {
652+ //shit's out of range, man
653+ throw new docIface . dDocException ( "dispMsg() error" ,
654+ "Invalid message slot" , 3 ) ;
655+ } else if ( ptr > base . last_msg ) {
656+ console . putmsg ( yellow + "Your message # was over the top; " +
657+ "pointing you at the last message\n" ) ;
658+ ptr = base . last_msg ;
659+ }
660+
626661 //try/catch this
627662 try {
628663 mHdr = base . get_msg_header ( ptr ) ;
629664 mBody = base . get_msg_body ( ptr ) ;
630665 } catch ( e ) {
631666 console . putmsg ( red + "Error fetching mHdr & mBody\nName: " + e . name +
632667 "\tNumber: " + e . number + "\nMessage: " + e . message + "\n" ) ;
633- throw new dDocException ( "dispMsg() Error" ,
668+ throw new docIface . dDocException ( "dispMsg() Error" ,
634669 "Unable to fetch message header/body" , 1 ) ;
635670 }
636671
0 commit comments