From 58bc55b9685508743270c1529d61706fde7648a4 Mon Sep 17 00:00:00 2001 From: ronny Date: Mon, 26 Nov 2001 14:40:02 +0000 Subject: bug fix in initialisation git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@904 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d --- backendC/CleanCompilerSources/backend.c | 16 ++++++++++++---- backendC/CleanCompilerSources/sa.c | 5 +++-- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'backendC') diff --git a/backendC/CleanCompilerSources/backend.c b/backendC/CleanCompilerSources/backend.c index 74e2b3b..1c979d1 100644 --- a/backendC/CleanCompilerSources/backend.c +++ b/backendC/CleanCompilerSources/backend.c @@ -3411,10 +3411,18 @@ BEStrictPositions (int functionIndex, int *bits, int **positions) strict_positions = ruleType->type_alt_strict_positions; - Assert (strict_positions != NULL); - - *bits = strict_positions->sp_size; - *positions = strict_positions->sp_bits; + if (strict_positions == NULL) + { + /* this can happen if sa is turned of, or if the sa has failed + (for example when it's out of memory) */ + *bits = 0; + *positions = NULL; + } + else + { + *bits = strict_positions->sp_size; + *positions = strict_positions->sp_bits; + } } /* BEStrictPositions */ int diff --git a/backendC/CleanCompilerSources/sa.c b/backendC/CleanCompilerSources/sa.c index 4bc3d66..9ab5754 100644 --- a/backendC/CleanCompilerSources/sa.c +++ b/backendC/CleanCompilerSources/sa.c @@ -2910,10 +2910,11 @@ static void StrictPositionsClear (void) { int sizeBytes; - sizeInts = bits2ints(kMaxStrictPositions); + sizeInts = bits2ints(kMaxStrictBits); sizeBytes = sizeof (StrictPositionsS) + (sizeInts-1) * sizeof (int); strict_positions = CompAlloc (sizeBytes); - + for (i = 0; i < sizeInts; i++) + strict_positions->sp_bits[i] = 0; strict_positions->sp_size = 0; } -- cgit v1.2.3