Skip to content

Commit

Permalink
handle memory allocation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chipitsine committed Oct 19, 2024
1 parent 9667dc1 commit 77a621e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ini/iniObjectInsert.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ int iniObjectInsert( HINI hIni, char *pszObject )

/* CREATE OBJECT STRUCT */
hObject = malloc( sizeof(INIOBJECT) );
if ( !hObject )
return INI_ERROR;
hIni->hCurProperty = NULL;
hObject->hFirstProperty = NULL;
hObject->hLastProperty = NULL;
Expand Down
4 changes: 4 additions & 0 deletions ini/iniOpen.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ int iniOpen( HINI *hIni, char *pszFileName, char *cComment, char cLeftBracket, c

/* INIT STATEMENT */
*hIni = malloc( sizeof(INI) );
if ( !*hIni )
return INI_ERROR;
if ( pszFileName && pszFileName != STDINFILE )
strncpy((*hIni)->szFileName, pszFileName, ODBC_FILENAME_MAX );
else if ( pszFileName == STDINFILE )
Expand Down Expand Up @@ -363,6 +365,8 @@ int iniOpen( HINI *hIni, char *pszFileName, char *cComment, char cLeftBracket, c

/* INIT STATEMENT */
*hIni = malloc( sizeof(INI) );
if ( !*hIni )
return INI_ERROR;
if ( pszFileName && pszFileName != STDINFILE )
strncpy((*hIni)->szFileName, pszFileName, ODBC_FILENAME_MAX );
else if ( pszFileName == STDINFILE )
Expand Down
2 changes: 2 additions & 0 deletions log/logOpen.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ int logOpen( HLOG *phLog, char *pszProgramName, char *pszLogFile, long nMaxMsgs

/* LOG STRUCT */
*phLog = malloc( sizeof(LOG) );
if ( !*phLog )
return LOG_ERROR;
(*phLog)->nMaxMsgs = nMaxMsgs;
(*phLog)->hMessages = lstOpen();
(*phLog)->bOn = 0;
Expand Down

0 comments on commit 77a621e

Please sign in to comment.