diff --git a/src/template.cpp b/src/template.cpp
index ec8554b..eca6158 100644
--- a/src/template.cpp
+++ b/src/template.cpp
@@ -1319,7 +1319,13 @@ class FilterDivisibleBy
       }
       if (v.type()==TemplateVariant::Integer && n.type()==TemplateVariant::Integer)
       {
-        return TemplateVariant((v.toInt()%n.toInt())==0);
+		const int nInt = n.toInt();
+		// avoid modulo by zero
+		if(nInt == 0)
+		{
+			return TemplateVariant();
+		}
+        return TemplateVariant((v.toInt()%nInt)==0);
       }
       else
       {
