if(section->mUsed < section->mLength)
if(section && section->mUsed < section->mLength)
int map2tsv(Options* inOptions)/***  Read all input.**  Output tab seperated value data.*/{    int retval = 0;    MSMap_Module module;    memset(&module, 0, sizeof(module));    /*    **  Read in the map file.    */    retval = readmap(inOptions, &module);    if(0 == retval)    {        unsigned symLoop = 0;        MSMap_Symbol* symbol = NULL;        unsigned secLoop = 0;        MSMap_Segment* section = NULL;        unsigned size = 0;        unsigned dbSize = 0;        unsigned offsetSize = 0;        unsigned endOffset = 0;        /*        **  Quick sort the symbols via RVABase.        */        qsort(module.mSymbols, module.mSymbolCount, sizeof(MSMap_Symbol), qsortRVABase);        /*        **  Go through all the symbols (in order by sort).        **  Output their sizes.        */        for(symLoop = 0; 0 == retval && symLoop < module.mSymbolCount; symLoop++)        {            symbol = &module.mSymbols[symLoop];            section = getSymbolSection(&module, symbol);            /*            **  Use the symbol DB size if available.            */            dbSize = symbol->mSymDBSize;            /*            **  Guess using offsets.            **  Is there a next symbol available?  If so, it's start offset is the end of this symbol.            **  Otherwise, our section offset + length is the end of this symbol.            **            **  The trick is, the DB size can not go beyond the offset size, for sanity.            */                        /*            **  Try next symbol, but only if in same section.            **  If still not, use the end of the segment.            **  This implies we were the last symbol in the segment.            */            if((symLoop + 1) < module.mSymbolCount)            {                MSMap_Symbol* nextSymbol = NULL;                MSMap_Segment* nextSection = NULL;                                nextSymbol = &module.mSymbols[symLoop + 1];                nextSection = getSymbolSection(&module, nextSymbol);                                if(section == nextSection)                {                    endOffset = nextSymbol->mOffset;                }                else                {                    endOffset = section->mOffset + section->mLength;                }            }            else            {                endOffset = section->mOffset + section->mLength;            }            /*            **  Can now guess at size.            */            offsetSize = endOffset - symbol->mOffset;            /*            **  Now, determine which size to use.            **  This is really a sanity check as well.            */            size = offsetSize;            if(0 != dbSize)            {                if(dbSize < offsetSize)                {                    size = dbSize;                }            }            /*            **  Output the symbol with the size.            */            retval = tsvout(inOptions,                size,                section->mClass,                symbol->mScope,                module.mModule,                section->mSegment,                symbol->mObject,                symbol->mSymbol                );            /*            **  Make sure we mark this amount of space as used in the section.            */            section->mUsed += size;        }        /*        **  Go through the sections, and those whose length is longer than the        **      amount of space used, output dummy filler values.        */        for(secLoop = 0; 0 == retval && secLoop < module.mSegmentCount; secLoop++)        {            section = &module.mSegments[secLoop];            if(section->mUsed < section->mLength)            {                retval = tsvout(inOptions,                    section->mLength - section->mUsed,                    section->mClass,                    UNDEFINED,                    module.mModule,                    section->mSegment,                    NULL,                    NULL                    );            }        }    }    /*    **  Cleanup.    */    cleanModule(&module);    return retval;}