Skip to content

Commit

Permalink
fix checkVisibility
Browse files Browse the repository at this point in the history
The checkVisibility function did not check its arguments' validity, leaving open the possibility of a null pointer access.
  • Loading branch information
Goober5000 committed Apr 18, 2024
1 parent 7acf56f commit 0a59c53
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion code/scripting/api/objs/ship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,12 @@ ADE_FUNC(checkVisibility,
object_h* v1 = nullptr;
object_h* v2 = nullptr;
if (!ade_get_args(L, "o|o", l_Ship.GetPtr(&v1), l_Ship.GetPtr(&v2)))
return ade_set_error(L, "o", "");
return ade_set_error(L, "i", 0);
if (!v1 || !v1->isValid())
return ade_set_error(L, "i", 0);
if (v2 && !v2->isValid())
return ade_set_error(L, "i", 0);

ship* viewer_shipp = nullptr;
ship* viewed_shipp = nullptr;
viewed_shipp = &Ships[v1->objp->instance];
Expand Down

0 comments on commit 0a59c53

Please sign in to comment.