I think I've got it working... My solution: Using the ${Else} GotoNextPage clause, but only if the previously visited page was
before MyCustomPage.
!define PAGE_NUMBER_MyCustomPage 7
Function MyCustomPage
${If} $MyVar == "ShowThePage"
nsDialogs::Create 1018
Pop $2
StrCpy $PREVIOUSPAGE ${PAGE_NUMBER_MyCustomPage}
nsDialogs::Show
${ElseIf} $PREVIOUSPAGE < ${PAGE_NUMBER_MyCustomPage}
StrCpy $PREVIOUSPAGE ${PAGE_NUMBER_MyCustomPage}
SendMessage $HWNDPARENT "0x408" "1" ""
${EndIf}
FunctionEnd
And then of course updating $PREVIOUSPAGE in every page, just before I leave it.
After the installer jumps forward six pages, the ${ElseIf} statement will force it to go forward one more. (Of course the next page should always be shown. If it's another conditional page, I guess you'd need to make it jump forward yet again in the ${Else} case.) This way, the installer will always reach a real page that it can actually draw, preventing it from crashing.
Naturally if the user clicks the Back button the ${ElseIf} statement will not be true, and there will again not be any page to draw. But this is no problem because the installer will then just go back yet another page. The crash only occurs when
manually jumping pages using SendMessage.