Index: opencv/modules/objdetect/src/distancetransform.cpp =================================================================== --- opencv/modules/objdetect/src/distancetransform.cpp (revision 6748) +++ opencv/modules/objdetect/src/distancetransform.cpp (working copy) @@ -347,10 +347,9 @@ int size = n * m; // Allocation memory (must be free in this function) - internalDistTrans = (float *)malloc(sizeof(float) * size); + internalDistTrans = (float *)malloc(sizeof(float) * size); internalPointsX = (int *)malloc(sizeof(int) * size); - for (i = 0; i < n; i++) { resOneDimProblem = DistanceTransformOneDimensionalProblem( @@ -361,6 +360,7 @@ if (resOneDimProblem != DISTANCE_TRANSFORM_OK) { free(internalDistTrans); + free(internalPointsX); return DISTANCE_TRANSFORM_ERROR; } /* if (resOneDimProblem != DISTANCE_TRANSFORM_OK) */ } @@ -375,6 +375,7 @@ if (resOneDimProblem != DISTANCE_TRANSFORM_OK) { free(internalDistTrans); + free(internalPointsX); return DISTANCE_TRANSFORM_ERROR; } /* if (resOneDimProblem != DISTANCE_TRANSFORM_OK) */ }