Skip to content

Commit ed98c0a

Browse files
Add input shapes validation
1 parent b039b87 commit ed98c0a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/net.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,6 +2218,10 @@ int Extractor::input(int blob_index, const Mat& in)
22182218
if (blob_index < 0 || blob_index >= (int)d->blob_mats.size())
22192219
return -1;
22202220

2221+
Mat shape = d->net->blobs()[blob_index].shape;
2222+
if (shape.total() && (shape.w != in.w) && (shape.h != in.h) && (shape.d != in.d) && (shape.c != in.c))
2223+
return -1;
2224+
22212225
d->blob_mats[blob_index] = in;
22222226

22232227
return 0;

0 commit comments

Comments
 (0)