]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix undefined behavior when advancing nullptr 17512/head
authorDaniel Arndt <arndtd@ornl.gov>
Tue, 13 Aug 2024 19:29:13 +0000 (13:29 -0600)
committerDaniel Arndt <arndtd@ornl.gov>
Tue, 13 Aug 2024 19:32:23 +0000 (13:32 -0600)
include/deal.II/dofs/dof_accessor.templates.h

index 93702dbce2a3aa602c590d1887b598ec7c98be47..c3afa34c61f0c3191bb88f0796ef1c5f9d3d6229 100644 (file)
@@ -533,11 +533,15 @@ namespace internal
           object_dof_indices.data() + range.first;
 
         // process dofs
-        for (unsigned int i = 0; i < range.second; ++i, ++dof_indices_ptr)
-          process(
-            stored_indices[(structdim == 0 || structdim == dim) ? i :
-                                                                  mapping(i)],
-            dof_indices_ptr);
+        for (unsigned int i = 0; i < range.second; ++i)
+          {
+            process(
+              stored_indices[(structdim == 0 || structdim == dim) ? i :
+                                                                    mapping(i)],
+              dof_indices_ptr);
+            if (dof_indices_ptr != nullptr)
+              ++dof_indices_ptr;
+          }
       }
 
 
@@ -1143,8 +1147,11 @@ namespace internal
             dof_indices_ptr,
             dof_processor);
 
-        AssertDimension(n_dof_indices(accessor, fe_index, count_level_dofs),
-                        dof_indices_ptr - get_array_ptr(const_dof_indices));
+        if (dof_indices_ptr != nullptr)
+          {
+            AssertDimension(n_dof_indices(accessor, fe_index, count_level_dofs),
+                            dof_indices_ptr - get_array_ptr(const_dof_indices));
+          }
 
         // PM: This is a part that should not be reached since it indicates that
         // an object (and/or its subobjects) is not active. However,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.