Fix various query related memory leaks.
This commit is contained in:
parent
428567098d
commit
744e22c7df
|
@ -757,19 +757,15 @@ UINT MSI_SetPropertyW( MSIPACKAGE *package, LPCWSTR szName, LPCWSTR szValue)
|
|||
MSI_RecordSetStringW(row,2,szValue);
|
||||
}
|
||||
|
||||
|
||||
rc = MSI_DatabaseOpenViewW(package->db,Query,&view);
|
||||
if (rc!= ERROR_SUCCESS)
|
||||
if (rc == ERROR_SUCCESS)
|
||||
{
|
||||
msiobj_release(&row->hdr);
|
||||
return rc;
|
||||
rc = MSI_ViewExecute(view,row);
|
||||
|
||||
MSI_ViewClose(view);
|
||||
msiobj_release(&view->hdr);
|
||||
}
|
||||
|
||||
rc = MSI_ViewExecute(view,row);
|
||||
|
||||
msiobj_release(&row->hdr);
|
||||
MSI_ViewClose(view);
|
||||
msiobj_release(&view->hdr);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -189,6 +189,7 @@ static UINT SELECT_delete( struct tagMSIVIEW *view )
|
|||
|
||||
if( sv->table )
|
||||
sv->table->ops->delete( sv->table );
|
||||
sv->table = NULL;
|
||||
|
||||
msi_free( sv );
|
||||
|
||||
|
@ -278,13 +279,10 @@ UINT SELECT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table,
|
|||
columns = columns->next;
|
||||
}
|
||||
|
||||
if( r != ERROR_SUCCESS )
|
||||
{
|
||||
sv->view.ops->delete( &sv->view );
|
||||
sv = NULL;
|
||||
}
|
||||
|
||||
*view = &sv->view;
|
||||
if( r == ERROR_SUCCESS )
|
||||
*view = &sv->view;
|
||||
else
|
||||
msi_free( sv );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -349,11 +349,15 @@ unorderedsel:
|
|||
| TK_SELECT TK_DISTINCT selectfrom
|
||||
{
|
||||
SQL_input* sql = (SQL_input*) info;
|
||||
UINT r;
|
||||
|
||||
$$ = NULL;
|
||||
DISTINCT_CreateView( sql->db, &$$, $3 );
|
||||
if( !$$ )
|
||||
r = DISTINCT_CreateView( sql->db, &$$, $3 );
|
||||
if (r != ERROR_SUCCESS)
|
||||
{
|
||||
$3->ops->delete($3);
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -361,15 +365,20 @@ selectfrom:
|
|||
selcollist from
|
||||
{
|
||||
SQL_input* sql = (SQL_input*) info;
|
||||
UINT r;
|
||||
|
||||
$$ = NULL;
|
||||
if( $1 )
|
||||
SELECT_CreateView( sql->db, &$$, $2, $1 );
|
||||
{
|
||||
r = SELECT_CreateView( sql->db, &$$, $2, $1 );
|
||||
if (r != ERROR_SUCCESS)
|
||||
{
|
||||
$2->ops->delete($2);
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
else
|
||||
$$ = $2;
|
||||
|
||||
if( !$$ )
|
||||
YYABORT;
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -394,8 +403,11 @@ from:
|
|||
|
||||
$$ = NULL;
|
||||
r = WHERE_CreateView( sql->db, &$$, $1, $3 );
|
||||
if( r != ERROR_SUCCESS || !$$ )
|
||||
if( r != ERROR_SUCCESS )
|
||||
{
|
||||
$1->ops->delete( $1 );
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -641,7 +653,7 @@ int SQL_lex( void *SQL_lval, SQL_input *sql )
|
|||
if( ! sql->command[sql->n] )
|
||||
return 0; /* end of input */
|
||||
|
||||
TRACE("string : %s\n", debugstr_w(&sql->command[sql->n]));
|
||||
/* TRACE("string : %s\n", debugstr_w(&sql->command[sql->n])); */
|
||||
sql->len = sqliteGetToken( &sql->command[sql->n], &token );
|
||||
if( sql->len==0 )
|
||||
break;
|
||||
|
@ -650,7 +662,7 @@ int SQL_lex( void *SQL_lval, SQL_input *sql )
|
|||
}
|
||||
while( token == TK_SPACE );
|
||||
|
||||
TRACE("token : %d (%s)\n", token, debugstr_wn(&sql->command[sql->n], sql->len));
|
||||
/* TRACE("token : %d (%s)\n", token, debugstr_wn(&sql->command[sql->n], sql->len)); */
|
||||
|
||||
return token;
|
||||
}
|
||||
|
@ -800,8 +812,6 @@ UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview,
|
|||
TRACE("Parse returned %d\n", r);
|
||||
if( r )
|
||||
{
|
||||
if( *sql.view )
|
||||
(*sql.view)->ops->delete( *sql.view );
|
||||
*sql.view = NULL;
|
||||
return ERROR_BAD_QUERY_SYNTAX;
|
||||
}
|
||||
|
|
|
@ -209,8 +209,7 @@ UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
|
|||
r = WHERE_CreateView( db, &wv, tv, expr );
|
||||
if( r != ERROR_SUCCESS )
|
||||
{
|
||||
if( sv )
|
||||
sv->ops->delete( tv );
|
||||
tv->ops->delete( tv );
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -218,8 +217,7 @@ UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
|
|||
r = SELECT_CreateView( db, &sv, wv, columns );
|
||||
if( r != ERROR_SUCCESS )
|
||||
{
|
||||
if( tv )
|
||||
tv->ops->delete( sv );
|
||||
wv->ops->delete( wv );
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -242,6 +242,7 @@ static UINT WHERE_execute( struct tagMSIVIEW *view, MSIRECORD *record )
|
|||
if( r != ERROR_SUCCESS )
|
||||
return r;
|
||||
|
||||
msi_free( wv->reorder );
|
||||
wv->reorder = msi_alloc( count*sizeof(UINT) );
|
||||
if( !wv->reorder )
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
|
@ -328,6 +329,7 @@ static UINT WHERE_delete( struct tagMSIVIEW *view )
|
|||
|
||||
if( wv->table )
|
||||
wv->table->ops->delete( wv->table );
|
||||
wv->table = 0;
|
||||
|
||||
msi_free( wv->reorder );
|
||||
wv->reorder = NULL;
|
||||
|
@ -444,7 +446,7 @@ UINT WHERE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table,
|
|||
MSIWHEREVIEW *wv = NULL;
|
||||
UINT count = 0, r, valid = 0;
|
||||
|
||||
TRACE("%p\n", wv );
|
||||
TRACE("%p\n", table );
|
||||
|
||||
r = table->ops->get_dimensions( table, NULL, &count );
|
||||
if( r != ERROR_SUCCESS )
|
||||
|
|
Loading…
Reference in New Issue