From d785775f649b720d7d7abf648cc154aefaf77a67 Mon Sep 17 00:00:00 2001 From: Andrey Rogov Date: Fri, 28 Apr 2023 01:52:01 +0300 Subject: [PATCH] 1. Fix bug (using pDesign without check if == NULL) 2. Switch type of variables containing file size to (int => long) --- src/base/io/ioReadBlifMv.c | 10 +++++----- src/base/io/ioUtil.c | 4 +++- src/opt/sim/simUtils.c | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/base/io/ioReadBlifMv.c b/src/base/io/ioReadBlifMv.c index e5c6fe49e..c8c14581a 100644 --- a/src/base/io/ioReadBlifMv.c +++ b/src/base/io/ioReadBlifMv.c @@ -548,10 +548,10 @@ typedef struct buflist { struct buflist * next; } buflist; -char * Io_MvLoadFileBz2( char * pFileName, int * pnFileSize ) +char * Io_MvLoadFileBz2( char * pFileName, long * pnFileSize ) { FILE * pFile; - int nFileSize = 0; + long nFileSize = 0; char * pContents; BZFILE * b; int bzError, RetValue; @@ -628,12 +628,12 @@ char * Io_MvLoadFileBz2( char * pFileName, int * pnFileSize ) SeeAlso [] ***********************************************************************/ -static char * Io_MvLoadFileGz( char * pFileName, int * pnFileSize ) +static char * Io_MvLoadFileGz( char * pFileName, long * pnFileSize ) { const int READ_BLOCK_SIZE = 100000; gzFile pFile; char * pContents; - int amtRead, readBlock, nFileSize = READ_BLOCK_SIZE; + long amtRead, readBlock, nFileSize = READ_BLOCK_SIZE; pFile = gzopen( pFileName, "rb" ); // if pFileName doesn't end in ".gz" then this acts as a passthrough to fopen pContents = ABC_ALLOC( char, nFileSize ); readBlock = 0; @@ -665,7 +665,7 @@ static char * Io_MvLoadFileGz( char * pFileName, int * pnFileSize ) static char * Io_MvLoadFile( char * pFileName ) { FILE * pFile; - int nFileSize; + long nFileSize; char * pContents; int RetValue; if ( !strncmp(pFileName+strlen(pFileName)-4,".bz2",4) ) diff --git a/src/base/io/ioUtil.c b/src/base/io/ioUtil.c index ddfcc91a8..156c9c1a4 100644 --- a/src/base/io/ioUtil.c +++ b/src/base/io/ioUtil.c @@ -157,8 +157,10 @@ Abc_Ntk_t * Io_ReadNetlist( char * pFileName, Io_FileType_t FileType, int fCheck fprintf( stdout, "Reading network from file has failed.\n" ); return NULL; } - if ( fCheck && (Abc_NtkBlackboxNum(pNtk) || Abc_NtkWhiteboxNum(pNtk)) ) + + if ( fCheck && (Abc_NtkBlackboxNum(pNtk) || Abc_NtkWhiteboxNum(pNtk)) && pNtk->pDesign ) { + int i, fCycle = 0; Abc_Ntk_t * pModel; // fprintf( stdout, "Warning: The network contains hierarchy.\n" ); diff --git a/src/opt/sim/simUtils.c b/src/opt/sim/simUtils.c index dc05df0f5..771577ca5 100644 --- a/src/opt/sim/simUtils.c +++ b/src/opt/sim/simUtils.c @@ -60,7 +60,8 @@ Vec_Ptr_t * Sim_UtilInfoAlloc( int nSize, int nWords, int fClean ) int i; assert( nSize > 0 && nWords > 0 ); vInfo = Vec_PtrAlloc( nSize ); - vInfo->pArray[0] = ABC_ALLOC( unsigned, nSize * nWords ); + vInfo->pArray[0] = ABC_ALLOC( unsigned, (long)nSize * (long)nWords ); + assert( vInfo->pArray[0]); if ( fClean ) memset( vInfo->pArray[0], 0, sizeof(unsigned) * nSize * nWords ); for ( i = 1; i < nSize; i++ )