Bug 665217. Handling corrupt statements in finally blocks. [r=zpao]

This commit is contained in:
Jared Wein 2011-06-21 10:44:10 -07:00
parent 2fbc4a0b6c
commit f34da59f4f

View File

@ -349,8 +349,10 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("_addLogin failed: " + e.name + " : " + e.message); this.log("_addLogin failed: " + e.name + " : " + e.message);
throw "Couldn't write to database, login not added."; throw "Couldn't write to database, login not added.";
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
}
// Send a notification that a login was added. // Send a notification that a login was added.
if (!isEncrypted) if (!isEncrypted)
@ -378,8 +380,10 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("_removeLogin failed: " + e.name + " : " + e.message); this.log("_removeLogin failed: " + e.name + " : " + e.message);
throw "Couldn't write to database, login not removed."; throw "Couldn't write to database, login not removed.";
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
}
this._sendNotification("removeLogin", storedLogin); this._sendNotification("removeLogin", storedLogin);
}, },
@ -517,8 +521,10 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("modifyLogin failed: " + e.name + " : " + e.message); this.log("modifyLogin failed: " + e.name + " : " + e.message);
throw "Couldn't write to database, login not modified."; throw "Couldn't write to database, login not modified.";
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
}
this._sendNotification("modifyLogin", [oldStoredLogin, newLogin]); this._sendNotification("modifyLogin", [oldStoredLogin, newLogin]);
}, },
@ -665,8 +671,10 @@ LoginManagerStorage_mozStorage.prototype = {
} catch (e) { } catch (e) {
this.log("_searchLogins failed: " + e.name + " : " + e.message); this.log("_searchLogins failed: " + e.name + " : " + e.message);
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
}
this.log("_searchLogins: returning " + logins.length + " logins"); this.log("_searchLogins: returning " + logins.length + " logins");
return [logins, ids]; return [logins, ids];
@ -693,8 +701,10 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("_removeAllLogins failed: " + e.name + " : " + e.message); this.log("_removeAllLogins failed: " + e.name + " : " + e.message);
throw "Couldn't write to database"; throw "Couldn't write to database";
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
}
this._sendNotification("removeAllLogins", null); this._sendNotification("removeAllLogins", null);
}, },
@ -750,8 +760,10 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("setLoginSavingEnabled failed: " + e.name + " : " + e.message); this.log("setLoginSavingEnabled failed: " + e.name + " : " + e.message);
throw "Couldn't write to database" throw "Couldn't write to database"
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
}
this._sendNotification(enabled ? "hostSavingEnabled" : "hostSavingDisabled", hostname); this._sendNotification(enabled ? "hostSavingEnabled" : "hostSavingDisabled", hostname);
}, },
@ -805,8 +817,10 @@ LoginManagerStorage_mozStorage.prototype = {
} catch (e) { } catch (e) {
this.log("_countLogins failed: " + e.name + " : " + e.message); this.log("_countLogins failed: " + e.name + " : " + e.message);
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
}
this.log("_countLogins: counted logins: " + numLogins); this.log("_countLogins: counted logins: " + numLogins);
return numLogins; return numLogins;
@ -905,8 +919,10 @@ LoginManagerStorage_mozStorage.prototype = {
} catch (e) { } catch (e) {
this.log("_queryDisabledHosts failed: " + e.name + " : " + e.message); this.log("_queryDisabledHosts failed: " + e.name + " : " + e.message);
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
}
return disabledHosts; return disabledHosts;
}, },
@ -1028,8 +1044,10 @@ LoginManagerStorage_mozStorage.prototype = {
} catch (e) { } catch (e) {
this.log("_isGuidUnique failed: " + e.name + " : " + e.message); this.log("_isGuidUnique failed: " + e.name + " : " + e.message);
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
}
return (numLogins == 0); return (numLogins == 0);
}, },
@ -1213,9 +1231,11 @@ LoginManagerStorage_mozStorage.prototype = {
// Ignore singular errors, continue trying to update others. // Ignore singular errors, continue trying to update others.
this.log("_reencryptBase64Logins caught error: " + e); this.log("_reencryptBase64Logins caught error: " + e);
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
} }
}
} catch (e) { } catch (e) {
this.log("_reencryptBase64Logins failed: " + e); this.log("_reencryptBase64Logins failed: " + e);
} finally { } finally {
@ -1386,8 +1406,10 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("Failed getting IDs: " + e); this.log("Failed getting IDs: " + e);
throw e; throw e;
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
}
// Generate a GUID for each login and update the DB. // Generate a GUID for each login and update the DB.
query = "UPDATE moz_logins SET guid = :guid WHERE id = :id"; query = "UPDATE moz_logins SET guid = :guid WHERE id = :id";
@ -1404,9 +1426,11 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("Failed setting GUID: " + e); this.log("Failed setting GUID: " + e);
throw e; throw e;
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
} }
}
}, },
@ -1447,8 +1471,10 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("Failed getting logins: " + e); this.log("Failed getting logins: " + e);
throw e; throw e;
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
}
// Determine encryption type for each login and update the DB. // Determine encryption type for each login and update the DB.
query = "UPDATE moz_logins SET encType = :encType WHERE id = :id"; query = "UPDATE moz_logins SET encType = :encType WHERE id = :id";
@ -1460,9 +1486,11 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("Failed setting encType: " + e); this.log("Failed setting encType: " + e);
throw e; throw e;
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
} }
}
}, },
@ -1495,8 +1523,10 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("Failed getting IDs: " + e); this.log("Failed getting IDs: " + e);
throw e; throw e;
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
}
// Initialize logins with current time. // Initialize logins with current time.
query = "UPDATE moz_logins SET timeCreated = :initTime, timeLastUsed = :initTime, " + query = "UPDATE moz_logins SET timeCreated = :initTime, timeLastUsed = :initTime, " +
@ -1514,9 +1544,11 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("Failed setting timestamps: " + e); this.log("Failed setting timestamps: " + e);
throw e; throw e;
} finally { } finally {
if (stmt) {
stmt.reset(); stmt.reset();
} }
} }
}
}, },