[MOAB-dev] r3819 - MOAB/trunk/src/io
smithrm at mcs.anl.gov
smithrm at mcs.anl.gov
Mon Apr 26 13:23:56 CDT 2010
Author: smithrm
Date: 2010-04-26 13:23:56 -0500 (Mon, 26 Apr 2010)
New Revision: 3819
Modified:
MOAB/trunk/src/io/ReadNCDF.cpp
Log:
o Added 3 NULL return checks in read_exodus_header(). Fixes ticket #6.
Modified: MOAB/trunk/src/io/ReadNCDF.cpp
===================================================================
--- MOAB/trunk/src/io/ReadNCDF.cpp 2010-04-26 18:19:56 UTC (rev 3818)
+++ MOAB/trunk/src/io/ReadNCDF.cpp 2010-04-26 18:23:56 UTC (rev 3819)
@@ -371,7 +371,12 @@
// get the word size, scalar value
NcAtt *temp_att = ncFile->get_att("floating_point_word_size");
- if (!temp_att->is_valid() || temp_att->type() != ncInt || temp_att->num_vals() != 1) {
+ if (NULL == temp_att || !temp_att->is_valid()) {
+ readMeshIface->report_error("ReadNCDF:: Problem getting floating_point_word_size attribute.");
+ delete temp_att;
+ return MB_FAILURE;
+ }
+ if (temp_att->type() != ncInt || temp_att->num_vals() != 1) {
readMeshIface->report_error("ReadNCDF:: Word size didn't have type int or size 1.");
return MB_FAILURE;
}
@@ -380,7 +385,12 @@
// exodus version
temp_att = ncFile->get_att("version");
- if (!temp_att->is_valid() || temp_att->type() != ncFloat || temp_att->num_vals() != 1) {
+ if (NULL == temp_att || !temp_att->is_valid()) {
+ readMeshIface->report_error("ReadNCDF:: Problem getting version attribute.");
+ delete temp_att;
+ return MB_FAILURE;
+ }
+ if (temp_att->type() != ncFloat || temp_att->num_vals() != 1) {
readMeshIface->report_error("ReadNCDF:: Version didn't have type float or size 1.");
return MB_FAILURE;
}
@@ -403,7 +413,12 @@
// title
char *title = new char[max_line_length+1];
temp_att = ncFile->get_att("title");
- if (temp_att->is_valid() && temp_att->num_vals() == 1) {
+ if (NULL == temp_att || !temp_att->is_valid()) {
+ readMeshIface->report_error("ReadNCDF:: Problem getting title attribute.");
+ delete temp_att;
+ return MB_FAILURE;
+ }
+ if (temp_att->num_vals() == 1) {
char *dum_str = temp_att->as_string(0);
strcpy(title, dum_str);
delete dum_str;
More information about the moab-dev
mailing list