diff --git a/Solver/linearSystemPETSc.cpp b/Solver/linearSystemPETSc.cpp
index 2516b5de5d9c7e53726f483a69e009bda2c4b46e..822be8e8c02fa2ab4f2b860eaa7056a55dd8c8c6 100644
--- a/Solver/linearSystemPETSc.cpp
+++ b/Solver/linearSystemPETSc.cpp
@@ -70,6 +70,8 @@ template<>
 void linearSystemPETSc<fullMatrix<double> >::addToRightHandSide(int row,
                                                       const fullMatrix<double> &val)
 {
+  if (!_entriesPreAllocated)
+    preAllocateEntries();
   int blockSize;
   _try(MatGetBlockSize(_a, &blockSize));
   for (int ii = 0; ii < blockSize; ii++) {