Skip to content

Commit

Permalink
fix potential leak found by coverity
Browse files Browse the repository at this point in the history
*** CID 446774:  Resource leaks  (RESOURCE_LEAK)
/DriverManager/SQLDriverConnect.c: 469 in __get_pair()
463
464         __get_attr( cp, &keyword, &value );
465         if ( keyword )
466         {
467             con_p = malloc( sizeof( *con_p ));
468             if ( !con_p )
>>>     CID 446774:  Resource leaks  (RESOURCE_LEAK)
>>>     Variable "value" going out of scope leaks the storage it points to.
469                 return NULL;
470             con_p -> keyword = keyword;
471             con_p -> attribute = value;
472             return con_p;
473         }
474         else

*** CID 446773:  Resource leaks  (RESOURCE_LEAK)
/DriverManager/SQLDriverConnect.c: 469 in __get_pair()
463
464         __get_attr( cp, &keyword, &value );
465         if ( keyword )
466         {
467             con_p = malloc( sizeof( *con_p ));
468             if ( !con_p )
>>>     CID 446773:  Resource leaks  (RESOURCE_LEAK)
>>>     Variable "keyword" going out of scope leaks the storage it points to.
469                 return NULL;
470             con_p -> keyword = keyword;
471             con_p -> attribute = value;
472             return con_p;
473         }
474         else
  • Loading branch information
chipitsine committed Oct 27, 2024
1 parent 58414fe commit f43a3f4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions DriverManager/SQLDriverConnect.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,12 @@ struct con_pair * con_p;
{
con_p = malloc( sizeof( *con_p ));
if ( !con_p )
{
free(keyword);
if ( value )
free(value);
return NULL;
}
con_p -> keyword = keyword;
con_p -> attribute = value;
return con_p;
Expand Down

0 comments on commit f43a3f4

Please sign in to comment.