Skip to content

Commit

Permalink
Applied patch from Darryl Miles that prevents a segfault on an
Browse files Browse the repository at this point in the history
error in "extresist".  The underlying error still exists and
causes a "Bad Device" error but no longer crashes magic.  See
github Issue #353.
  • Loading branch information
RTimothyEdwards committed Dec 26, 2024
1 parent df19d62 commit f80540a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions resis/ResJunct.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ ResNewSDDevice(tile, tp, xj, yj, direction, PendingList)
tileJunk *j;

newnode = FALSE;

/* Watch for invalid client data. If found, a "Bad Device" error will
* be generated which means "more debugging needed"; however, it will
* not cause a segmentation violation.
*/
if (tp->ti_client == CLIENTDEFAULT) return;

j = (tileJunk *) tp->ti_client;
resDev = j->deviceList;
if ((j->sourceEdge & direction) != 0)
Expand Down
9 changes: 7 additions & 2 deletions resis/ResMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,12 @@ ResGetDevice(pt, type)
return (((tileJunk *)tile->ti_client)->deviceList);
}
else if (TTMaskHasType(&ExtCurStyle->exts_deviceMask, TiGetType(tile)))
return (((tileJunk *)tile->ti_client)->deviceList);

{
/* Failure to have a valid client data will result in a "Bad Device"
* error and indicates a problem that needs debugging.
*/
if (tile->ti_client != CLIENTDEFAULT)
return (((tileJunk *)tile->ti_client)->deviceList);
}
return NULL;
}

0 comments on commit f80540a

Please sign in to comment.