Skip to content

Commit 4ca8d51

Browse files
committed
Fix null-pointer dereference
I had never seen `face_tracker_dlib::set_position` was called without it's texture for many years. However, I saw `p->tex` was NULL while developing another code. It would be safe to ensure the pointer is valid.
1 parent 66f9591 commit 4ca8d51

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/face-tracker-dlib.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ void face_tracker_dlib::set_texture(std::shared_ptr<texture_object> &tex)
6060

6161
void face_tracker_dlib::set_position(const rect_s &rect)
6262
{
63+
if (!p->tex)
64+
return;
6365
p->rect.x0 = rect.x0 / p->tex->scale;
6466
p->rect.y0 = rect.y0 / p->tex->scale;
6567
p->rect.x1 = rect.x1 / p->tex->scale;

0 commit comments

Comments
 (0)