Skip to content

Commit 7f95140

Browse files
committed
fix: improve img validation to handle numpy arrays safely
1 parent 97c560e commit 7f95140

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: |
2424
python -m pip install --upgrade pip
2525
pip install setuptools wheel twine poetry
26-
poetry lock --no-update
26+
poetry lock
2727
poetry install
2828
2929
- name: Get the version from the tag

hmdriver2/_client.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
UITEST_SERVICE_PORT = 8012
1919
SOCKET_TIMEOUT = 20
20-
ASSETS_PATH = os.path.join(os.path.dirname(__file__), "assets")
21-
AGENT_CLEAR_PATH = ["app", "commons-", "agent", "libagent_antry"]
2220

2321

2422
class HmClient:

hmdriver2/_screenrecord.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- coding: utf-8 -*-
2-
import queue
2+
33
import typing
44
import threading
55
import numpy as np
6-
from queue import Queue
6+
import queue
77
from datetime import datetime
88

99
import cv2
@@ -20,7 +20,7 @@ def __init__(self, serial: str, d: Driver):
2020
self.d = d
2121

2222
self.video_path = None
23-
self.jpeg_queue = Queue()
23+
self.jpeg_queue = queue.Queue()
2424
self.threads: typing.List[threading.Thread] = []
2525
self.stop_event = threading.Event()
2626

@@ -102,7 +102,7 @@ def _video_writer(self):
102102
img = cv2.imdecode(np.frombuffer(jpeg_image, np.uint8), cv2.IMREAD_COLOR)
103103
except queue.Empty:
104104
pass
105-
if not img:
105+
if img is None or img.size == 0:
106106
continue
107107
if cv2_instance is None:
108108
height, width = img.shape[:2]

0 commit comments

Comments
 (0)