Skip to content

Commit

Permalink
Merge branch 'develop' into 'develop'
Browse files Browse the repository at this point in the history
GR: ensure that sufficient memory has been allocated

See merge request Scientific-IT-Systems/gr!1300
  • Loading branch information
jheinen committed Jun 18, 2024
2 parents d088e64 + ccff069 commit e2cc758
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/gr/gr.c
Original file line number Diff line number Diff line change
Expand Up @@ -5434,7 +5434,7 @@ void gr_axis(char which, axis_t *axis)
axis->ticks = (double *)xcalloc(axis->num_ticks, sizeof(tick_t));
if (axis->major_count > 0)
{
axis->num_tick_labels = axis->num_ticks / axis->major_count;
axis->num_tick_labels = (int)(axis->num_ticks / axis->major_count + 0.5) + 1;
axis->tick_labels = (tick_label_t *)xcalloc(axis->num_tick_labels, sizeof(tick_label_t));
}
else
Expand Down Expand Up @@ -5476,6 +5476,15 @@ void gr_axis(char which, axis_t *axis)
axis->num_ticks = j;
axis->num_tick_labels = k;
}

if (axis->num_ticks > 0)
{
axis->ticks = (tick_t *)xrealloc(axis->ticks, axis->num_ticks * sizeof(tick_t));
}
if (axis->num_tick_labels > 0)
{
axis->tick_labels = (tick_label_t *)xrealloc(axis->tick_labels, axis->num_tick_labels * sizeof(tick_label_t));
}
}

void gr_drawaxis(char which, axis_t *axis)
Expand Down

0 comments on commit e2cc758

Please sign in to comment.