Skip to content

Commit f80540a

Browse files
Applied patch from Darryl Miles that prevents a segfault on an
error in "extresist". The underlying error still exists and causes a "Bad Device" error but no longer crashes magic. See github Issue #353.
1 parent df19d62 commit f80540a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

resis/ResJunct.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ ResNewSDDevice(tile, tp, xj, yj, direction, PendingList)
5555
tileJunk *j;
5656

5757
newnode = FALSE;
58+
59+
/* Watch for invalid client data. If found, a "Bad Device" error will
60+
* be generated which means "more debugging needed"; however, it will
61+
* not cause a segmentation violation.
62+
*/
63+
if (tp->ti_client == CLIENTDEFAULT) return;
64+
5865
j = (tileJunk *) tp->ti_client;
5966
resDev = j->deviceList;
6067
if ((j->sourceEdge & direction) != 0)

resis/ResMain.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,12 @@ ResGetDevice(pt, type)
17251725
return (((tileJunk *)tile->ti_client)->deviceList);
17261726
}
17271727
else if (TTMaskHasType(&ExtCurStyle->exts_deviceMask, TiGetType(tile)))
1728-
return (((tileJunk *)tile->ti_client)->deviceList);
1729-
1728+
{
1729+
/* Failure to have a valid client data will result in a "Bad Device"
1730+
* error and indicates a problem that needs debugging.
1731+
*/
1732+
if (tile->ti_client != CLIENTDEFAULT)
1733+
return (((tileJunk *)tile->ti_client)->deviceList);
1734+
}
17301735
return NULL;
17311736
}

0 commit comments

Comments
 (0)