Skip to content

Commit

Permalink
Do not crash when reading a parameter
Browse files Browse the repository at this point in the history
The filterSimulationResults API expects only variables when converting
to CSV. This adds a check to see if a parameter was passed instead.
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Nov 10, 2016
1 parent 40b6e79 commit 54ab0e4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Compiler/runtime/SimulationResults.c
Expand Up @@ -453,7 +453,13 @@ int SimulationResults_filterSimulationResults(const char *inFile, const char *ou
c_add_message(NULL,-1, ErrorType_scripting, ErrorLevel_error, gettext("Could not read variable %s in file %s."), msg, 2);
return 0;
}
vals[i] = omc_matlab4_read_vals(&simresglob.matReader, mat_var[i]->index);
if (mat_var[i]->isParam) {
msg[0] = var;
c_add_message(NULL,-1, ErrorType_scripting, ErrorLevel_error, gettext("Could not filter parameter %s since the output format is CSV (only variables are allowed)."), msg, 1);
return 0;
} else {
vals[i] = omc_matlab4_read_vals(&simresglob.matReader, mat_var[i]->index);
}
}
fout = fopen(outFile, "w");
fprintf(fout, "time");
Expand Down

0 comments on commit 54ab0e4

Please sign in to comment.