1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 07:13:02 +04:00

Fix copyTo on empty fixed-type matrices (#28343)

PR #27972 added _dst.create(size(), type()) in copyTo's empty() block.
In Debug builds, Mat::release() was resetting flags to MAGIC_VAL,
clearing the type information and causing assertion failures when
destination has fixedType().

Preserve type flags in Mat::release() debug mode by using:
  flags = (flags & CV_MAT_TYPE_MASK) | MAGIC_VAL

Thanks to @akretz for suggesting this better approach.
This commit is contained in:
WalkingDevFlag
2026-01-05 14:34:38 +05:30
parent f3758f40ae
commit 175dd57bdd
2 changed files with 20 additions and 1 deletions
+1 -1
View File
@@ -553,7 +553,7 @@ void Mat::release()
for(int i = 0; i < dims; i++)
size.p[i] = 0;
#ifdef _DEBUG
flags = MAGIC_VAL;
flags = (flags & CV_MAT_TYPE_MASK) | MAGIC_VAL;
dims = rows = cols = 0;
if(step.p != step.buf)
{