diff --git a/control/descriptor_helpers.c b/control/descriptor_helpers.c
index f11e487d32d578577534de023b37179765e263ff..87846e3a5709f9127aaf3fa4dfc72084ab3ae469 100644
--- a/control/descriptor_helpers.c
+++ b/control/descriptor_helpers.c
@@ -139,6 +139,15 @@ int chameleon_getrankof_custom_init( custom_dist_t **custom_dist,
         return CHAMELEON_ERR_ILLEGAL_VALUE;
     }
 
+    if ( (dist_m <= 0 ) || (dist_n <= 0) ) {
+        char message[300];
+        snprintf( message, 300, "Incorrect values for dist_m(%d) and/or dist_n(%d)", dist_m, dist_n );
+        chameleon_error( "chameleon_getrankof_custom_init", message );
+        free( result );
+        fclose( f );
+        return CHAMELEON_ERR_ILLEGAL_VALUE;
+    }
+
     result->dist_m = dist_m;
     result->dist_n = dist_n;