From 25cc8a96ef22df5c8d6951c159045ae4e6d94807 Mon Sep 17 00:00:00 2001 From: 19igari <71631129+19igari@users.noreply.github.com> Date: Wed, 22 May 2024 10:41:04 +0900 Subject: [PATCH] fix(modeld): Fix for unpredictable behavior in commonmodel_pyx.pyx (#32482) Avoid undefined behavior Co-authored-by: 19igari --- selfdrive/modeld/models/commonmodel_pyx.pyx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/selfdrive/modeld/models/commonmodel_pyx.pyx b/selfdrive/modeld/models/commonmodel_pyx.pyx index e33d301aff..bc59b7a233 100644 --- a/selfdrive/modeld/models/commonmodel_pyx.pyx +++ b/selfdrive/modeld/models/commonmodel_pyx.pyx @@ -37,7 +37,11 @@ cdef class ModelFrame: def prepare(self, VisionBuf buf, float[:] projection, CLMem output): cdef mat3 cprojection memcpy(cprojection.v, &projection[0], 9*sizeof(float)) - cdef float * data = self.frame.prepare(buf.buf.buf_cl, buf.width, buf.height, buf.stride, buf.uv_offset, cprojection, output.mem) + cdef float * data + if output is None: + data = self.frame.prepare(buf.buf.buf_cl, buf.width, buf.height, buf.stride, buf.uv_offset, cprojection, NULL) + else: + data = self.frame.prepare(buf.buf.buf_cl, buf.width, buf.height, buf.stride, buf.uv_offset, cprojection, output.mem) if not data: return None return np.asarray( data)