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,7 +349,9 @@ 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 {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
// Send a notification that a login was added. // Send a notification that a login was added.
@ -378,7 +380,9 @@ 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 {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
this._sendNotification("removeLogin", storedLogin); this._sendNotification("removeLogin", storedLogin);
@ -517,7 +521,9 @@ 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 {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
this._sendNotification("modifyLogin", [oldStoredLogin, newLogin]); this._sendNotification("modifyLogin", [oldStoredLogin, newLogin]);
@ -665,7 +671,9 @@ 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 {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
this.log("_searchLogins: returning " + logins.length + " logins"); this.log("_searchLogins: returning " + logins.length + " logins");
@ -693,7 +701,9 @@ 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 {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
this._sendNotification("removeAllLogins", null); this._sendNotification("removeAllLogins", null);
@ -750,7 +760,9 @@ 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 {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
this._sendNotification(enabled ? "hostSavingEnabled" : "hostSavingDisabled", hostname); this._sendNotification(enabled ? "hostSavingEnabled" : "hostSavingDisabled", hostname);
@ -805,7 +817,9 @@ 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 {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
this.log("_countLogins: counted logins: " + numLogins); this.log("_countLogins: counted logins: " + numLogins);
@ -905,7 +919,9 @@ 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 {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
return disabledHosts; return disabledHosts;
@ -1028,7 +1044,9 @@ 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 {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
return (numLogins == 0); return (numLogins == 0);
@ -1213,7 +1231,9 @@ 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 {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
} }
} catch (e) { } catch (e) {
@ -1386,7 +1406,9 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("Failed getting IDs: " + e); this.log("Failed getting IDs: " + e);
throw e; throw e;
} finally { } finally {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
// Generate a GUID for each login and update the DB. // Generate a GUID for each login and update the DB.
@ -1404,7 +1426,9 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("Failed setting GUID: " + e); this.log("Failed setting GUID: " + e);
throw e; throw e;
} finally { } finally {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
} }
}, },
@ -1447,7 +1471,9 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("Failed getting logins: " + e); this.log("Failed getting logins: " + e);
throw e; throw e;
} finally { } finally {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
// Determine encryption type for each login and update the DB. // Determine encryption type for each login and update the DB.
@ -1460,7 +1486,9 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("Failed setting encType: " + e); this.log("Failed setting encType: " + e);
throw e; throw e;
} finally { } finally {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
} }
}, },
@ -1495,7 +1523,9 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("Failed getting IDs: " + e); this.log("Failed getting IDs: " + e);
throw e; throw e;
} finally { } finally {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
// Initialize logins with current time. // Initialize logins with current time.
@ -1514,7 +1544,9 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("Failed setting timestamps: " + e); this.log("Failed setting timestamps: " + e);
throw e; throw e;
} finally { } finally {
stmt.reset(); if (stmt) {
stmt.reset();
}
} }
} }
}, },