Skip to content

Commit

Permalink
fixed segfault in realloc index for #1869
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathadon committed Apr 14, 2024
1 parent e2e6b85 commit dc5ce85
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions IBPSA/Resources/C-Sources/WeeklySchedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ void* weeklyScheduleInit(const int tableOnFile, const char* name, const double t
ModelicaFormatError("Too many columns on data line %i when reading weekly schedule '%s'. %i instead of %i.", line, name, tokensInLine + 1, tokensInFirstLine);
}else if (tokensInLine >= n_reservedColumns) { /* This code should only be reached upon passing the first line of data */
n_reservedColumns += allocSize;
scheduleID->rules[rule_i]->data = (double*)realloc(scheduleID->rules[rule_i]->data, sizeof(double)*n_reservedColumns);
if ( scheduleID->rules[rule_i]->data == NULL){
scheduleID->rules[rule_i-1]->data = (double*)realloc(scheduleID->rules[rule_i-1]->data, sizeof(double)*n_reservedColumns);
if ( scheduleID->rules[rule_i-1]->data == NULL){
weeklyScheduleFreeInit(scheduleID);
weeklyScheduleFree(scheduleID);
ModelicaFormatError("Failed to allocate memory for rules[rule_i]->data in WeeklySchedule.c.");
ModelicaFormatError("Failed to reallocate memory for rules[rule_i-1]->data in WeeklySchedule.c.");
}
}

Expand Down

0 comments on commit dc5ce85

Please sign in to comment.