From 51111176dbd9039cf7b842b7d2620222f144d751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 25 Oct 2011 19:34:32 +0200 Subject: [PATCH] Guard against 'bc' being NULL. This is in preparation of introducing compressible boundary conditions as represented by the 'compr_bc' module. --- src/cfs_tpfa_residual.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cfs_tpfa_residual.c b/src/cfs_tpfa_residual.c index 721c70f74..5517f81a4 100644 --- a/src/cfs_tpfa_residual.c +++ b/src/cfs_tpfa_residual.c @@ -612,7 +612,8 @@ compute_fpress(grid_t *G, c1 = G->face_cells[2*f + 0]; c2 = G->face_cells[2*f + 1]; - if (((c1 < 0) || (c2 < 0)) && (bc->type[f] == PRESSURE)) { + if (((c1 < 0) || (c2 < 0)) && + (bc != NULL) && (bc->type[f] == PRESSURE)) { fpress[f] = bc->bcval[f]; } } @@ -638,7 +639,8 @@ compute_flux(grid_t *G, c1 = G->face_cells[2*f + 0]; c2 = G->face_cells[2*f + 1]; - if (((c1 < 0) || (c2 < 0)) && (bc->type[f] == FLUX)) { + if (((c1 < 0) || (c2 < 0)) && + (bc != NULL) && (bc->type[f] == FLUX)) { fflux[f] = bc->bcval[f]; continue; } @@ -652,7 +654,7 @@ compute_flux(grid_t *G, if ((c1 >= 0) && (c2 >= 0)) { dp = cpress[c1] - cpress[c2]; - } else if (bc->type[f] == PRESSURE) { + } else if ((bc != NULL) && (bc->type[f] == PRESSURE)) { if (c1 < 0) { dp = bc->bcval[f] - cpress[c2]; /* g = -g; */