Skip to content

Commit

Permalink
in case that mallooc fails
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Sep 13, 2024
1 parent b955a19 commit f052250
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/driver/drv_charts.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,14 @@ chart_t *Chart_Create(int maxSamples, int numVars, int numAxes) {
for (int i = 0; i < numVars; i++) {
s->vars[i].samples = (float*)ZeroMalloc(sizeof(float) * maxSamples);
if (s->vars[i].samples == 0) {
// TODO
for (int j = 0; j < i; j++) {
free(s->vars[j].samples);
}
free(s->times);
free(s->axes);
free(s->vars);
free(s);
return NULL;
}
}
s->numAxes = numAxes;
Expand Down

0 comments on commit f052250

Please sign in to comment.