From f8d7977b360e4756d0aa045a7396756973c1568c Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 7 Dec 2001 20:37:18 +0000 Subject: [PATCH] Owen's patch to allow PowerMenu (third-party transparency tool) to not crash PuTTY. git-svn-id: svn://svn.tartarus.org/sgt/putty@1463 cda61777-01e9-0310-a592-d414129be87e --- window.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/window.c b/window.c index d9939fd8..15f23870 100644 --- a/window.c +++ b/window.c @@ -1561,15 +1561,20 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, sprintf(c, "putty &%p", filemap); cl = c; } else if (wParam == IDM_SAVEDSESS) { - char *session = - sessions[(lParam - IDM_SAVED_MIN) / 16]; - cl = smalloc(16 + strlen(session)); /* 8, but play safe */ - if (!cl) - cl = NULL; /* not a very important failure mode */ - else { - sprintf(cl, "putty @%s", session); - freecl = TRUE; - } + if ((lParam - IDM_SAVED_MIN) / 16 < nsessions) { + char *session = + sessions[(lParam - IDM_SAVED_MIN) / 16]; + cl = smalloc(16 + strlen(session)); + /* 8, but play safe */ + if (!cl) + cl = NULL; + /* not a very important failure mode */ + else { + sprintf(cl, "putty @%s", session); + freecl = TRUE; + } + } else + break; } else cl = NULL; -- 2.11.0