Skip to content

Commit

Permalink
Handle memory allocation errors (#195)
Browse files Browse the repository at this point in the history
* handle memory allocation errors

* handle memory allocation errors
  • Loading branch information
chipitsine authored Oct 19, 2024
1 parent 2234e8b commit 9667dc1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions DriverManager/SQLDriverConnect.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ struct con_pair * con_p;
if ( keyword )
{
con_p = malloc( sizeof( *con_p ));
if ( !con_p )
return NULL;
con_p -> keyword = keyword;
con_p -> attribute = value;
return con_p;
Expand Down
10 changes: 10 additions & 0 deletions odbcinst/SQLCreateDataSource.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ char* _multi_string_alloc_and_copy( LPCWSTR in )
}

chr = malloc( len + 2 );
if ( !chr )
return NULL;

len = 0;
while ( in[ len ] != 0 || in[ len + 1 ] != 0 )
Expand Down Expand Up @@ -80,6 +82,8 @@ char* _single_string_alloc_and_copy( LPCWSTR in )
}

chr = malloc( ulen + 1 );
if ( !chr )
return NULL;

len = 0;
ulen = 0;
Expand Down Expand Up @@ -127,6 +131,8 @@ char* _single_string_alloc_and_copy( LPCWSTR in )
}

chr = malloc( len + 1 );
if ( !chr )
return NULL;

len = 0;
while ( in[ len ] != 0 )
Expand Down Expand Up @@ -157,6 +163,8 @@ SQLWCHAR* _multi_string_alloc_and_expand( LPCSTR in )
}

chr = malloc(sizeof( SQLWCHAR ) * ( len + 2 ));
if ( !chr )
return NULL;

len = 0;
while ( in[ len ] != 0 || in[ len + 1 ] != 0 )
Expand Down Expand Up @@ -186,6 +194,8 @@ SQLWCHAR* _single_string_alloc_and_expand( LPCSTR in )
}

chr = malloc( sizeof( SQLWCHAR ) * ( len + 1 ));
if ( !chr )
return NULL;

len = 0;
while ( in[ len ] != 0 )
Expand Down

0 comments on commit 9667dc1

Please sign in to comment.