Skip to content

Commit

Permalink
- fix wrong string buffer size calculations in fmi import
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16714 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Matthias Arzt committed Aug 1, 2013
1 parent 8e822ec commit a79ba42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions SimulationRuntime/c/fmi/FMI1ModelExchange.c
Expand Up @@ -53,7 +53,7 @@ void* FMI1ModelExchangeConstructor_OMC(int fmi_log_level, char* working_director
FMI1ME->FMICallbackFunctions.allocateMemory = calloc;
FMI1ME->FMICallbackFunctions.freeMemory = free;
/* parse the xml file */
FMI1ME->FMIWorkingDirectory = (char*) malloc(strlen(working_directory));
FMI1ME->FMIWorkingDirectory = (char*) malloc(strlen(working_directory)+1);
strcpy(FMI1ME->FMIWorkingDirectory, working_directory);
FMI1ME->FMIImportInstance = fmi1_import_parse_xml(FMI1ME->FMIImportContext, FMI1ME->FMIWorkingDirectory);
if(!FMI1ME->FMIImportInstance) {
Expand All @@ -67,7 +67,7 @@ void* FMI1ModelExchangeConstructor_OMC(int fmi_log_level, char* working_director
fprintf(stderr, "Could not create the DLL loading mechanism(C-API).\n");
return 0;
}
FMI1ME->FMIInstanceName = (char*) malloc(strlen(instanceName));
FMI1ME->FMIInstanceName = (char*) malloc(strlen(instanceName)+1);
strcpy(FMI1ME->FMIInstanceName, instanceName);
FMI1ME->FMIDebugLogging = debugLogging;
fmi1_import_instantiate_model(FMI1ME->FMIImportInstance, FMI1ME->FMIInstanceName);
Expand Down
4 changes: 2 additions & 2 deletions SimulationRuntime/c/fmi/FMI2ModelExchange.c
Expand Up @@ -53,7 +53,7 @@ void* FMI2ModelExchangeConstructor_OMC(int fmi_log_level, char* working_director
FMI2ME->FMICallbackFunctions.allocateMemory = calloc;
FMI2ME->FMICallbackFunctions.freeMemory = free;
/* parse the xml file */
FMI2ME->FMIWorkingDirectory = (char*) malloc(strlen(working_directory));
FMI2ME->FMIWorkingDirectory = (char*) malloc(strlen(working_directory)+1);
strcpy(FMI2ME->FMIWorkingDirectory, working_directory);
FMI2ME->FMIImportInstance = fmi2_import_parse_xml(FMI2ME->FMIImportContext, FMI2ME->FMIWorkingDirectory, NULL);
if(!FMI2ME->FMIImportInstance) {
Expand All @@ -67,7 +67,7 @@ void* FMI2ModelExchangeConstructor_OMC(int fmi_log_level, char* working_director
fprintf(stderr, "Could not create the DLL loading mechanism(C-API).\n");
return 0;
}
FMI2ME->FMIInstanceName = (char*) malloc(strlen(instanceName));
FMI2ME->FMIInstanceName = (char*) malloc(strlen(instanceName)+1);
strcpy(FMI2ME->FMIInstanceName, instanceName);
FMI2ME->FMIDebugLogging = debugLogging;
fmi2_import_instantiate_model(FMI2ME->FMIImportInstance, FMI2ME->FMIInstanceName, NULL, fmi2_false);
Expand Down

0 comments on commit a79ba42

Please sign in to comment.