From 599ceed1a28d9ecf655af8faa2789d14f82b5295 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 24 Oct 2014 07:37:03 +0000 Subject: [PATCH] don't crash on bad input data --- Post/PViewDataGModel.h | 1 + Post/PViewDataGModelIO.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/Post/PViewDataGModel.h b/Post/PViewDataGModel.h index 226396bb00..10068b3122 100644 --- a/Post/PViewDataGModel.h +++ b/Post/PViewDataGModel.h @@ -114,6 +114,7 @@ class stepData{ } Real *getData(int index, bool allocIfNeeded=false, int mult=1) { + if(index < 0) return 0; if(allocIfNeeded){ if(index >= getNumData()) resizeData(index + 100); // optimize this if(!(*_data)[index]){ diff --git a/Post/PViewDataGModelIO.cpp b/Post/PViewDataGModelIO.cpp index 2aa3a337b4..991d1a0b5d 100644 --- a/Post/PViewDataGModelIO.cpp +++ b/Post/PViewDataGModelIO.cpp @@ -89,6 +89,7 @@ bool PViewDataGModel::readMSH(const std::string &viewName, const std::string &fi else{ if(fscanf(fp, "%d", &num) != 1) return false; } + if(num < 0) return false; int mult = 1; if(_type == ElementNodeData || _type == GaussPointData){ if(binary){ -- GitLab