Fixed a crash when trying to insert variables into the datasheet
authorJohn Darrington <john@cellform.com>
Wed, 21 Jun 2023 10:02:06 +0000 (12:02 +0200)
committerJohn Darrington <john@cellform.com>
Wed, 21 Jun 2023 10:02:06 +0000 (12:02 +0200)
src/data/datasheet.c

index 816b7150e28bf6dc05fe18bbf5a05aec4c48af3d..0e523a20d78541be395906d2755b52d1ce40f5b6 100644 (file)
@@ -418,11 +418,12 @@ datasheet_move_columns (struct datasheet *ds,
                         size_t old_start, size_t new_start,
                         size_t n)
 {
-  assert (old_start + n <= ds->n_columns);
   assert (new_start + n <= ds->n_columns);
-
-  move_range (ds->columns, ds->n_columns, sizeof *ds->columns,
-              old_start, new_start, n);
+  if  (old_start + n <= ds->n_columns)
+    {
+      move_range (ds->columns, ds->n_columns, sizeof *ds->columns,
+                  old_start, new_start, n);
+    }
 
   caseproto_unref (ds->proto);
   ds->proto = NULL;