Commit 002c5574 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Check that cells has parts before accessing them

parent ffbf1f31
...@@ -3411,7 +3411,7 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs, ...@@ -3411,7 +3411,7 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs,
if (s->cells_top != NULL && s->nr_parts > 0) { if (s->cells_top != NULL && s->nr_parts > 0) {
for (int i = 0; i < s->nr_cells; i++) { for (int i = 0; i < s->nr_cells; i++) {
struct cell *c = &s->cells_top[i]; struct cell *c = &s->cells_top[i];
if (c->nodeID == engine_rank) { if (c->nodeID == engine_rank && c->count > 0) {
float part_h_max = c->parts[0].h; float part_h_max = c->parts[0].h;
for (int k = 1; k < c->count; k++) { for (int k = 1; k < c->count; k++) {
if (c->parts[k].h > part_h_max) part_h_max = c->parts[k].h; if (c->parts[k].h > part_h_max) part_h_max = c->parts[k].h;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment