diff --git a/python/plugins/processing/tests/testdata/expected/difference_points_vs_polys.gml b/python/plugins/processing/tests/testdata/expected/difference_points_vs_polys.gml
new file mode 100644
index 00000000000..8a509811a50
--- /dev/null
+++ b/python/plugins/processing/tests/testdata/expected/difference_points_vs_polys.gml
@@ -0,0 +1,79 @@
+
+
+ -5 02 8
+
+
+
+ points.0
+ 1
+ 2
+
+
+
+
+ points.1
+ 2
+ 1
+
+
+
+
+ points.2
+ 3
+ 0
+
+
+
+
+ 2 52 5
+ 2 5
+ points.3
+ 4
+ 2
+
+
+
+
+ points.4
+ 5
+ 1
+
+
+
+
+ -5 0-5 0
+ -5 0
+ points.5
+ 6
+ 0
+
+
+
+
+ -1 8-1 8
+ -1 8
+ points.6
+ 7
+ 0
+
+
+
+
+ points.7
+ 8
+ 0
+
+
+
+
+ points.8
+ 9
+ 0
+
+
+
diff --git a/python/plugins/processing/tests/testdata/expected/difference_points_vs_polys.xsd b/python/plugins/processing/tests/testdata/expected/difference_points_vs_polys.xsd
new file mode 100644
index 00000000000..bfb7a760091
--- /dev/null
+++ b/python/plugins/processing/tests/testdata/expected/difference_points_vs_polys.xsd
@@ -0,0 +1,67 @@
+
+
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/python/plugins/processing/tests/testdata/qgis_algorithm_tests4.yaml b/python/plugins/processing/tests/testdata/qgis_algorithm_tests4.yaml
index 1738bcb1349..114228694fe 100644
--- a/python/plugins/processing/tests/testdata/qgis_algorithm_tests4.yaml
+++ b/python/plugins/processing/tests/testdata/qgis_algorithm_tests4.yaml
@@ -435,6 +435,24 @@ tests:
geometry:
normalize: True
+ - algorithm: native:difference
+ name: Difference points vs polys
+ params:
+ INPUT:
+ name: points.gml|layername=points
+ type: vector
+ OVERLAY:
+ name: polys.gml|layername=polys2
+ type: vector
+ results:
+ OUTPUT:
+ name: expected/difference_points_vs_polys.gml
+ type: vector
+ compare:
+ fields:
+ fid: skip
+ gml_id: skip
+
- algorithm: native:symmetricaldifference
name: Test Symmetrical Difference A - B (basic)
params:
diff --git a/src/analysis/processing/qgsoverlayutils.cpp b/src/analysis/processing/qgsoverlayutils.cpp
index 1efaa4a2b95..0b492f1ef6f 100644
--- a/src/analysis/processing/qgsoverlayutils.cpp
+++ b/src/analysis/processing/qgsoverlayutils.cpp
@@ -163,7 +163,7 @@ void QgsOverlayUtils::difference( const QgsFeatureSource &sourceA, const QgsFeat
geom = geom.difference( geomB );
}
- if ( !sanitizeDifferenceResult( geom, geometryType ) )
+ if ( !geom.isNull() && !sanitizeDifferenceResult( geom, geometryType ) )
continue;
const QgsAttributes attrsA( featA.attributes() );