From a069f0ac7b072e01b8152a92cc9e7a2777ed8a4f Mon Sep 17 00:00:00 2001 From: vissssa Date: Wed, 31 Mar 2021 19:49:45 +0800 Subject: [PATCH] fix: invalid mask will cause process exit --- PythonAPI/pycocotools/_mask.pyx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PythonAPI/pycocotools/_mask.pyx b/PythonAPI/pycocotools/_mask.pyx index d065837f..79ed7d79 100644 --- a/PythonAPI/pycocotools/_mask.pyx +++ b/PythonAPI/pycocotools/_mask.pyx @@ -146,6 +146,11 @@ def decode(rleObjs): cdef RLEs Rs = _frString(rleObjs) h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n masks = Masks(h, w, n) + count =0 + for i in range(Rs._R[0].m): + count+=Rs._R[0].cnts[i] + if count>h*w*n: + raise Exception("invalid mask") rleDecode(Rs._R, masks._mask, n); return np.array(masks)