URL強調時にバッファ外にアクセスしてクラッシュする場合があったので修正
- [Ttssh2-devel 4600]
- r8765
@@ -35,9 +35,7 @@ | ||
35 | 35 | #include <windows.h> |
36 | 36 | #define _CRTDBG_MAP_ALLOC |
37 | 37 | #include <crtdbg.h> |
38 | -#include <mbstring.h> | |
39 | 38 | #include <assert.h> |
40 | -#include <errno.h> | |
41 | 39 | |
42 | 40 | #include "tttypes.h" |
43 | 41 | #include "ttwinman.h" |
@@ -723,7 +721,7 @@ | ||
723 | 721 | } |
724 | 722 | } |
725 | 723 | |
726 | -void EraseKanjiOnLRMargin(LONG ptr, int count) | |
724 | +static void EraseKanjiOnLRMargin(LONG ptr, int count) | |
727 | 725 | { |
728 | 726 | int i; |
729 | 727 | LONG pos; |
@@ -1484,6 +1482,7 @@ | ||
1484 | 1482 | BuffUpdateRect(0, YStart, NumOfColumns-1, YEnd); |
1485 | 1483 | } |
1486 | 1484 | |
1485 | +// TODO rename | |
1487 | 1486 | static int LeftHalfOfDBCS(LONG Line, int CharPtr) |
1488 | 1487 | // If CharPtr is on the right half of a DBCS character, |
1489 | 1488 | // return pointer to the left half |
@@ -2377,10 +2376,12 @@ | ||
2377 | 2376 | // 行末を探す |
2378 | 2377 | ex = NumOfColumns - 1; |
2379 | 2378 | ey = cur_y; |
2380 | - TmpPtr = GetLinePtr(PageStart + ey); | |
2381 | - while ((CodeBuffW[TmpPtr + NumOfColumns - 1].attr & AttrLineContinued) != 0) { | |
2382 | - ey++; | |
2383 | - TmpPtr = NextLinePtr(TmpPtr); | |
2379 | + if (cur_y < NumOfLines - 1) { | |
2380 | + TmpPtr = GetLinePtr(PageStart + ey); | |
2381 | + while ((CodeBuffW[TmpPtr + NumOfColumns - 1].attr & AttrLineContinued) != 0) { | |
2382 | + ey++; | |
2383 | + TmpPtr = NextLinePtr(TmpPtr); | |
2384 | + } | |
2384 | 2385 | } |
2385 | 2386 | b = &CodeBuffW[TmpPtr + ex]; |
2386 | 2387 | for (;;) { |
@@ -2438,6 +2439,9 @@ | ||
2438 | 2439 | |
2439 | 2440 | // 次のセルへ |
2440 | 2441 | if (sx_i == NumOfColumns - 1) { |
2442 | + if (sy_i == NumOfLines - 1) { | |
2443 | + break; | |
2444 | + } | |
2441 | 2445 | sx_i = 0; |
2442 | 2446 | sy_i++; |
2443 | 2447 | } |
@@ -2465,7 +2469,7 @@ | ||
2465 | 2469 | } |
2466 | 2470 | |
2467 | 2471 | /** |
2468 | - * カーソル位置からURL強調を行う | |
2472 | + * (cur_x, cur_y)位置からURL強調を行う | |
2469 | 2473 | */ |
2470 | 2474 | static void mark_url_w(int cur_x, int cur_y) |
2471 | 2475 | { |
@@ -2546,12 +2550,13 @@ | ||
2546 | 2550 | } |
2547 | 2551 | |
2548 | 2552 | // '/' が入力されたら調べ始める |
2549 | - if (u32 == '/') { | |
2550 | - if (!MatchString(x - 2, PageStart + CursorY, L"://", TRUE)) { | |
2551 | - // "://" の一部ではない | |
2552 | - return; | |
2553 | - } | |
2553 | + if (u32 != '/') { | |
2554 | + return; | |
2554 | 2555 | } |
2556 | + if (!MatchString(x - 2, PageStart + CursorY, L"://", TRUE)) { | |
2557 | + // "://" の一部ではない | |
2558 | + return; | |
2559 | + } | |
2555 | 2560 | |
2556 | 2561 | // 本格的に探す |
2557 | 2562 | for (i = 0; i < _countof(schemes); i++) { |
@@ -2595,7 +2600,7 @@ | ||
2595 | 2600 | int xx = sx; |
2596 | 2601 | size_t left = len + 1; |
2597 | 2602 | while (left > 0) { |
2598 | - CodeLineW[TmpPtr + xx].attr |= AttrURL; | |
2603 | + CodeBuffW[TmpPtr + xx].attr |= AttrURL; | |
2599 | 2604 | xx++; |
2600 | 2605 | if (xx == NumOfColumns) { |
2601 | 2606 | int draw_x = sx; |