1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Fix memory allocation problem in the sqlite_get_table() API. Ticket #315. (CVS 976)

FossilOrigin-Name: f1d955efd91093994db43a1540080d32442d5ac0
This commit is contained in:
drh
2003-05-17 00:05:49 +00:00
parent a996e477d0
commit 9335247003
3 changed files with 10 additions and 8 deletions

View File

@ -172,10 +172,11 @@ int sqlite_get_table(
if( res.nAlloc>res.nData ){
char **azNew;
azNew = realloc( res.azResult, sizeof(char*)*(res.nData+1) );
if( res.azResult==0 ){
if( azNew==0 ){
sqlite_free_table(&res.azResult[1]);
return SQLITE_NOMEM;
}
res.nAlloc = res.nData+1;
res.azResult = azNew;
}
*pazResult = &res.azResult[1];
@ -193,6 +194,7 @@ void sqlite_free_table(
if( azResult ){
int i, n;
azResult--;
if( azResult==0 ) return;
n = (int)azResult[0];
for(i=1; i<n; i++){ if( azResult[i] ) free(azResult[i]); }
free(azResult);