Commit 1a708967 authored by Adrian Negreanu's avatar Adrian Negreanu

sqlite3: clear bindings on errors and more care with return

* call sqlite3_clear_bindings when step fails
* more miss-placed returns
Signed-off-by: 's avatarAdrian Negreanu <adrian.m.negreanu@intel.com>
parent 09a5fc19
...@@ -708,9 +708,9 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) ...@@ -708,9 +708,9 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def)
if (id_bfile == -1) if (id_bfile == -1)
{ {
sqlite3_clear_bindings(i_s_memberdef); sqlite3_clear_bindings(i_s_memberdef);
return;
} }
else
{
bindIntParameter(i_s_memberdef,":id_ibfile",id_bfile); bindIntParameter(i_s_memberdef,":id_ibfile",id_bfile);
bindIntParameter(i_s_memberdef,":bline",md->getStartBodyLine()); bindIntParameter(i_s_memberdef,":bline",md->getStartBodyLine());
...@@ -719,12 +719,13 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) ...@@ -719,12 +719,13 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def)
} }
} }
} }
}
if (-1==step(db,i_s_memberdef)) if (-1==step(db,i_s_memberdef))
{ {
sqlite3_clear_bindings(i_s_memberdef); sqlite3_clear_bindings(i_s_memberdef);
} }
/*int id_src =*/ sqlite3_last_insert_rowid(db); sqlite3_last_insert_rowid(db);
// + source references // + source references
// The cross-references in initializers only work when both the src and dst // The cross-references in initializers only work when both the src and dst
...@@ -825,8 +826,9 @@ static void generateSqlite3ForClass(sqlite3 *db, ClassDef *cd) ...@@ -825,8 +826,9 @@ static void generateSqlite3ForClass(sqlite3 *db, ClassDef *cd)
bindIntParameter(i_s_compounddef,":line",cd->getDefLine()); bindIntParameter(i_s_compounddef,":line",cd->getDefLine());
bindIntParameter(i_s_compounddef,":column",cd->getDefColumn()); bindIntParameter(i_s_compounddef,":column",cd->getDefColumn());
if (-1==step(db,i_s_compounddef)) if (-1==step(db,i_s_compounddef)) {
return; sqlite3_clear_bindings(i_s_compounddef);
}
// + list of direct super classes // + list of direct super classes
if (cd->baseClasses()) if (cd->baseClasses())
...@@ -848,10 +850,12 @@ static void generateSqlite3ForClass(sqlite3 *db, ClassDef *cd) ...@@ -848,10 +850,12 @@ static void generateSqlite3ForClass(sqlite3 *db, ClassDef *cd)
bindTextParameter(i_s_basecompoundref,":base",bcd->classDef->displayName()); bindTextParameter(i_s_basecompoundref,":base",bcd->classDef->displayName());
} }
bindTextParameter(i_s_basecompoundref,":derived",cd->displayName()); bindTextParameter(i_s_basecompoundref,":derived",cd->displayName());
if (-1==step(db,i_s_basecompoundref)) if (-1==step(db,i_s_basecompoundref)) {
sqlite3_clear_bindings(i_s_basecompoundref);
continue; continue;
} }
} }
}
// + list of direct sub classes // + list of direct sub classes
if (cd->subClasses()) if (cd->subClasses())
...@@ -865,10 +869,12 @@ static void generateSqlite3ForClass(sqlite3 *db, ClassDef *cd) ...@@ -865,10 +869,12 @@ static void generateSqlite3ForClass(sqlite3 *db, ClassDef *cd)
bindTextParameter(i_s_derivedcompoundref,":refid",bcd->classDef->getOutputFileBase()); bindTextParameter(i_s_derivedcompoundref,":refid",bcd->classDef->getOutputFileBase());
bindIntParameter(i_s_derivedcompoundref,":prot",bcd->prot); bindIntParameter(i_s_derivedcompoundref,":prot",bcd->prot);
bindIntParameter(i_s_derivedcompoundref,":virt",bcd->virt); bindIntParameter(i_s_derivedcompoundref,":virt",bcd->virt);
if (-1==step(db,i_s_derivedcompoundref)) if (-1==step(db,i_s_derivedcompoundref)) {
sqlite3_reset(i_s_derivedcompoundref);
continue; continue;
} }
} }
}
// + include file // + include file
IncludeInfo *ii=cd->includeInfo(); IncludeInfo *ii=cd->includeInfo();
...@@ -888,7 +894,7 @@ static void generateSqlite3ForClass(sqlite3 *db, ClassDef *cd) ...@@ -888,7 +894,7 @@ static void generateSqlite3ForClass(sqlite3 *db, ClassDef *cd)
bindIntParameter(i_s_includes,":id_src",id_file); bindIntParameter(i_s_includes,":id_src",id_file);
bindTextParameter(i_s_includes,":dst",nm); bindTextParameter(i_s_includes,":dst",nm);
if (-1==step(db,i_s_includes)) if (-1==step(db,i_s_includes))
return; sqlite3_clear_bindings(i_s_basecompoundref);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment