Skip to content

Commit 5e90802

Browse files
committed
Merge pull request opencv#18363 from alalek:issue_18349
2 parents 45fee13 + 261ad78 commit 5e90802

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

modules/core/src/matrix_wrap.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
12471247
{
12481248
CV_Assert( i < 0 );
12491249
Mat& m = *(Mat*)obj;
1250+
CV_Assert(!(m.empty() && fixedType() && fixedSize()) && "Can't reallocate empty Mat with locked layout (probably due to misused 'const' modifier)");
12501251
if (allowTransposed && !m.empty() &&
12511252
d == 2 && m.dims == 2 &&
12521253
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] &&
@@ -1260,13 +1261,13 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
12601261
if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
12611262
mtype = m.type();
12621263
else
1263-
CV_CheckTypeEQ(m.type(), CV_MAT_TYPE(mtype), "");
1264+
CV_CheckTypeEQ(m.type(), CV_MAT_TYPE(mtype), "Can't reallocate Mat with locked type (probably due to misused 'const' modifier)");
12641265
}
12651266
if(fixedSize())
12661267
{
1267-
CV_CheckEQ(m.dims, d, "");
1268+
CV_CheckEQ(m.dims, d, "Can't reallocate Mat with locked size (probably due to misused 'const' modifier)");
12681269
for(int j = 0; j < d; ++j)
1269-
CV_CheckEQ(m.size[j], sizes[j], "");
1270+
CV_CheckEQ(m.size[j], sizes[j], "Can't reallocate Mat with locked size (probably due to misused 'const' modifier)");
12701271
}
12711272
m.create(d, sizes, mtype);
12721273
return;
@@ -1276,6 +1277,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
12761277
{
12771278
CV_Assert( i < 0 );
12781279
UMat& m = *(UMat*)obj;
1280+
CV_Assert(!(m.empty() && fixedType() && fixedSize()) && "Can't reallocate empty UMat with locked layout (probably due to misused 'const' modifier)");
12791281
if (allowTransposed && !m.empty() &&
12801282
d == 2 && m.dims == 2 &&
12811283
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] &&
@@ -1289,13 +1291,13 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
12891291
if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
12901292
mtype = m.type();
12911293
else
1292-
CV_CheckTypeEQ(m.type(), CV_MAT_TYPE(mtype), "");
1294+
CV_CheckTypeEQ(m.type(), CV_MAT_TYPE(mtype), "Can't reallocate UMat with locked type (probably due to misused 'const' modifier)");
12931295
}
12941296
if(fixedSize())
12951297
{
1296-
CV_CheckEQ(m.dims, d, "");
1298+
CV_CheckEQ(m.dims, d, "Can't reallocate UMat with locked size (probably due to misused 'const' modifier)");
12971299
for(int j = 0; j < d; ++j)
1298-
CV_CheckEQ(m.size[j], sizes[j], "");
1300+
CV_CheckEQ(m.size[j], sizes[j], "Can't reallocate UMat with locked size (probably due to misused 'const' modifier)");
12991301
}
13001302
m.create(d, sizes, mtype);
13011303
return;

0 commit comments

Comments
 (0)