Skip to content

Commit 96269b1

Browse files
committed
Merge branch 'original'
2 parents cb1145b + d890ced commit 96269b1

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

ldmicro/CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11

2+
== Release 2.3
3+
4+
* Fix buffer overrun or write to null pointer if Windows sends an
5+
LVN_GETDISPINFO without a valid item.pszText, which happens now
6+
under Win10.
7+
28
== Release 2.2
39

410
* Fix a problem with the ANSI C target when the program had bit and

ldmicro/helpdialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ static char *AboutText[] = {
6363
"",
6464
" http://cq.cx/ladder.pl",
6565
"",
66-
"Copyright 2005-2010 Jonathan Westhues",
67-
"Release 2.2, built " __TIME__ " " __DATE__ ".",
66+
"Copyright 2005-2016 Jonathan Westhues",
67+
"Release 2.3, built " __TIME__ " " __DATE__ ".",
6868
"",
6969
"Email: user jwesthues, at host cq.cx",
7070
"",

ldmicro/intcode.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,13 @@ static void IntCodeFromCircuit(int which, void *any, char *stateInOut)
891891

892892
// This is a table of characters to transmit, as a function of the
893893
// sequencer position (though we might have a hole in the middle
894-
// for the variable output)
895-
char outputChars[MAX_LOOK_UP_TABLE_LEN];
894+
// for the variable output); positive is an unsigned character,
895+
// negative is special flag values
896+
enum {
897+
OUTPUT_DIGIT = -1,
898+
OUTPUT_SIGN = -2,
899+
};
900+
int outputChars[MAX_LOOK_UP_TABLE_LEN];
896901

897902
BOOL mustDoMinus = FALSE;
898903

@@ -917,7 +922,7 @@ static void IntCodeFromCircuit(int which, void *any, char *stateInOut)
917922
p++;
918923
if(*p == '-') {
919924
mustDoMinus = TRUE;
920-
outputChars[steps++] = 1;
925+
outputChars[steps++] = OUTPUT_SIGN;
921926
p++;
922927
}
923928
if(!isdigit(*p) || (*p - '0') > 5 || *p == '0') {
@@ -928,7 +933,7 @@ static void IntCodeFromCircuit(int which, void *any, char *stateInOut)
928933
digits = (*p - '0');
929934
int i;
930935
for(i = 0; i < digits; i++) {
931-
outputChars[steps++] = 0;
936+
outputChars[steps++] = OUTPUT_DIGIT;
932937
}
933938
} else if(*p == '\\') {
934939
p++;
@@ -960,7 +965,7 @@ static void IntCodeFromCircuit(int which, void *any, char *stateInOut)
960965
break;
961966
}
962967
} else {
963-
outputChars[steps++] = *p;
968+
outputChars[steps++] = (unsigned char)*p;
964969
}
965970
if(*p) p++;
966971
}
@@ -1013,7 +1018,7 @@ static void IntCodeFromCircuit(int which, void *any, char *stateInOut)
10131018
int i;
10141019
int digit = 0;
10151020
for(i = 0; i < steps; i++) {
1016-
if(outputChars[i] == 0) {
1021+
if(outputChars[i] == OUTPUT_DIGIT) {
10171022
// Note gross hack to work around limit of range for
10181023
// AVR brne op, which is +/- 64 instructions.
10191024
Op(INT_SET_VARIABLE_TO_LITERAL, "$scratch", i);
@@ -1063,7 +1068,7 @@ static void IntCodeFromCircuit(int which, void *any, char *stateInOut)
10631068
Op(INT_END_IF);
10641069

10651070
digit++;
1066-
} else if(outputChars[i] == 1) {
1071+
} else if(outputChars[i] == OUTPUT_SIGN) {
10671072
// do the minus; ugliness to get around the BRNE jump
10681073
// size limit, though
10691074
Op(INT_SET_VARIABLE_TO_LITERAL, "$scratch", i);

ldmicro/iolist.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,15 @@ void IoListProc(NMHDR *h)
772772
switch(h->code) {
773773
case LVN_GETDISPINFO: {
774774
NMLVDISPINFO *i = (NMLVDISPINFO *)h;
775+
if(!((i->item.mask & LVIF_TEXT) &&
776+
(i->item.pszText) &&
777+
(i->item.cchTextMax > 200)))
778+
{
779+
// This test didn't used to be present, and Windows 10 now
780+
// sends an LVN_GETDISPINFO that fails it, which would
781+
// otherwise cause us to write to a null pointer.
782+
break;
783+
}
775784
int item = i->item.iItem;
776785
switch(i->item.iSubItem) {
777786
case LV_IO_PIN:

0 commit comments

Comments
 (0)