• R/O
  • SSH
  • HTTPS

ttssh2: 提交


Commit MetaInfo

修订版8785 (tree)
时间2020-05-19 01:11:01
作者zmatsuo

Log Message

URL強調時にバッファ外にアクセスしてクラッシュする場合があったので修正

- [Ttssh2-devel 4600]
- r8765

更改概述

差异

--- trunk/teraterm/teraterm/buffer.c (revision 8784)
+++ trunk/teraterm/teraterm/buffer.c (revision 8785)
@@ -35,9 +35,7 @@
3535 #include <windows.h>
3636 #define _CRTDBG_MAP_ALLOC
3737 #include <crtdbg.h>
38-#include <mbstring.h>
3938 #include <assert.h>
40-#include <errno.h>
4139
4240 #include "tttypes.h"
4341 #include "ttwinman.h"
@@ -723,7 +721,7 @@
723721 }
724722 }
725723
726-void EraseKanjiOnLRMargin(LONG ptr, int count)
724+static void EraseKanjiOnLRMargin(LONG ptr, int count)
727725 {
728726 int i;
729727 LONG pos;
@@ -1484,6 +1482,7 @@
14841482 BuffUpdateRect(0, YStart, NumOfColumns-1, YEnd);
14851483 }
14861484
1485+// TODO rename
14871486 static int LeftHalfOfDBCS(LONG Line, int CharPtr)
14881487 // If CharPtr is on the right half of a DBCS character,
14891488 // return pointer to the left half
@@ -2377,10 +2376,12 @@
23772376 // 行末を探す
23782377 ex = NumOfColumns - 1;
23792378 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+ }
23842385 }
23852386 b = &CodeBuffW[TmpPtr + ex];
23862387 for (;;) {
@@ -2438,6 +2439,9 @@
24382439
24392440 // 次のセルへ
24402441 if (sx_i == NumOfColumns - 1) {
2442+ if (sy_i == NumOfLines - 1) {
2443+ break;
2444+ }
24412445 sx_i = 0;
24422446 sy_i++;
24432447 }
@@ -2465,7 +2469,7 @@
24652469 }
24662470
24672471 /**
2468- * カーソル位置からURL強調を行う
2472+ * (cur_x, cur_y)位置からURL強調を行う
24692473 */
24702474 static void mark_url_w(int cur_x, int cur_y)
24712475 {
@@ -2546,12 +2550,13 @@
25462550 }
25472551
25482552 // '/' が入力されたら調べ始める
2549- if (u32 == '/') {
2550- if (!MatchString(x - 2, PageStart + CursorY, L"://", TRUE)) {
2551- // "://" の一部ではない
2552- return;
2553- }
2553+ if (u32 != '/') {
2554+ return;
25542555 }
2556+ if (!MatchString(x - 2, PageStart + CursorY, L"://", TRUE)) {
2557+ // "://" の一部ではない
2558+ return;
2559+ }
25552560
25562561 // 本格的に探す
25572562 for (i = 0; i < _countof(schemes); i++) {
@@ -2595,7 +2600,7 @@
25952600 int xx = sx;
25962601 size_t left = len + 1;
25972602 while (left > 0) {
2598- CodeLineW[TmpPtr + xx].attr |= AttrURL;
2603+ CodeBuffW[TmpPtr + xx].attr |= AttrURL;
25992604 xx++;
26002605 if (xx == NumOfColumns) {
26012606 int draw_x = sx;
Show on old repository browser