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

set error to pParse and preserve internal invariant about possible error inside the condition #195

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
17 changes: 15 additions & 2 deletions libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -127426,12 +127426,20 @@ SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
pKey = sqlite3KeyInfoAlloc(pParse->db, nCol, 0);
}
if( pKey ){
iDb = sqlite3SchemaToIndex(pParse->db, pIdx->pSchema);
assert( sqlite3KeyInfoIsWriteable(pKey) );
pKey->zIndexName = sqlite3DbStrDup(pParse->db, pIdx->zName);

iDb = sqlite3SchemaToIndex(pParse->db, pIdx->pSchema);
if( 0 <= iDb && iDb < pParse->db->nDb ){
pKey->zDbSName = sqlite3DbStrDup(pParse->db, pParse->db->aDb[iDb].zDbSName);
if( pKey->zDbSName == NULL ){
goto out_nomem;
}
}
pKey->zIndexName = sqlite3DbStrDup(pParse->db, pIdx->zName);
if( pKey->zIndexName == NULL ){
goto out_nomem;
}

for(i=0; i<nCol; i++){
const char *zColl = pIdx->azColl[i];
pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :
Expand All @@ -127457,6 +127465,11 @@ SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
}
}
return pKey;
out_nomem:
if( pKey != NULL ){
sqlite3KeyInfoUnref(pKey);
}
return sqlite3OomFault(pParse->db);
}

#ifndef SQLITE_OMIT_CTE
Expand Down
17 changes: 15 additions & 2 deletions libsql-ffi/bundled/src/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -127426,12 +127426,20 @@ SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
pKey = sqlite3KeyInfoAlloc(pParse->db, nCol, 0);
}
if( pKey ){
iDb = sqlite3SchemaToIndex(pParse->db, pIdx->pSchema);
assert( sqlite3KeyInfoIsWriteable(pKey) );
pKey->zIndexName = sqlite3DbStrDup(pParse->db, pIdx->zName);

iDb = sqlite3SchemaToIndex(pParse->db, pIdx->pSchema);
if( 0 <= iDb && iDb < pParse->db->nDb ){
pKey->zDbSName = sqlite3DbStrDup(pParse->db, pParse->db->aDb[iDb].zDbSName);
if( pKey->zDbSName == NULL ){
goto out_nomem;
}
}
pKey->zIndexName = sqlite3DbStrDup(pParse->db, pIdx->zName);
if( pKey->zIndexName == NULL ){
goto out_nomem;
}

for(i=0; i<nCol; i++){
const char *zColl = pIdx->azColl[i];
pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :
Expand All @@ -127457,6 +127465,11 @@ SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
}
}
return pKey;
out_nomem:
if( pKey != NULL ){
sqlite3KeyInfoUnref(pKey);
}
return sqlite3OomFault(pParse->db);
}

#ifndef SQLITE_OMIT_CTE
Expand Down
17 changes: 15 additions & 2 deletions libsql-sqlite3/src/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -5635,12 +5635,20 @@ KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
pKey = sqlite3KeyInfoAlloc(pParse->db, nCol, 0);
}
if( pKey ){
iDb = sqlite3SchemaToIndex(pParse->db, pIdx->pSchema);
assert( sqlite3KeyInfoIsWriteable(pKey) );
pKey->zIndexName = sqlite3DbStrDup(pParse->db, pIdx->zName);

iDb = sqlite3SchemaToIndex(pParse->db, pIdx->pSchema);
if( 0 <= iDb && iDb < pParse->db->nDb ){
pKey->zDbSName = sqlite3DbStrDup(pParse->db, pParse->db->aDb[iDb].zDbSName);
if( pKey->zDbSName == NULL ){
goto out_nomem;
}
}
pKey->zIndexName = sqlite3DbStrDup(pParse->db, pIdx->zName);
if( pKey->zIndexName == NULL ){
goto out_nomem;
}

for(i=0; i<nCol; i++){
const char *zColl = pIdx->azColl[i];
pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :
Expand All @@ -5666,6 +5674,11 @@ KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
}
}
return pKey;
out_nomem:
if( pKey != NULL ){
sqlite3KeyInfoUnref(pKey);
}
return sqlite3OomFault(pParse->db);
}

#ifndef SQLITE_OMIT_CTE
Expand Down
Loading