Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle memory allocation errors #196

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cur/SQLExecDirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,23 @@ SQLRETURN get_column_names( CLHSTMT cl_statement )

cl_statement -> column_names = malloc( sizeof(char *)
* cl_statement -> column_count );
if ( !cl_statement->column_names )
return SQL_ERROR;

cl_statement -> data_type = malloc( sizeof( SQLSMALLINT )
* cl_statement -> column_count );
if ( !cl_statement->data_type )
return SQL_ERROR;

cl_statement -> column_size = malloc( sizeof( SQLULEN )
* cl_statement -> column_count );
if ( !cl_statement->column_size )
return SQL_ERROR;

cl_statement -> decimal_digits = malloc( sizeof( SQLSMALLINT )
* cl_statement -> column_count );
if ( !cl_statement->decimal_digits )
return SQL_ERROR;

for ( i = 1; i <= cl_statement -> column_count; i ++ )
{
Expand Down
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