From 79d1651a0bec601915aa333071a8e05edb5b1285 Mon Sep 17 00:00:00 2001 From: kvigor Date: Fri, 11 Apr 2003 16:12:29 +0000 Subject: [PATCH] Fix null pointer deref that caused build failures on Solaris git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2507 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCmem.c | 5 ++++- src/ds390/gen.c | 2 +- src/mcs51/gen.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/SDCCmem.c b/src/SDCCmem.c index 17a88598..6c5f0d87 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -1083,9 +1083,12 @@ doOverlays (eBBlock ** ebbs, int count) void printAllocInfo (symbol * func, FILE * of) { + if (!func) + return; + if (!of) of = stdout; - + /* must be called after register allocation is complete */ fprintf (of, ";------------------------------------------------------------\n"); fprintf (of, ";Allocation info for local variables in function '%s'\n", func->name); diff --git a/src/ds390/gen.c b/src/ds390/gen.c index ad5d8c4e..d417b07f 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -12697,7 +12697,7 @@ gen390Code (iCode * lic) } #if 1 /* print the allocation information */ - if (allocInfo) + if (allocInfo && currFunc) printAllocInfo (currFunc, codeOutFile); #endif /* if debug information required */ diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 9b28f9b4..473746c7 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -8879,7 +8879,7 @@ gen51Code (iCode * lic) lineHead = lineCurr = NULL; /* print the allocation information */ - if (allocInfo) + if (allocInfo && currFunc) printAllocInfo (currFunc, codeOutFile); /* if debug information required */ if (options.debug && currFunc) -- 2.30.2