Bug 461344 - abort if the version of sqlite we are using is not new enough
This adds a runtime check to ensure that the version of SQLite that is running
is the same as the one that we were compiled with. If the check fails, we will
display a prompt to the user, and abort.
r=bsmedberg
--- a/storage/src/mozStorageService.cpp
+++ b/storage/src/mozStorageService.cpp
@@ -41,32 +41,52 @@
#include "mozStorageService.h"
#include "mozStorageConnection.h"
#include "nsCRT.h"
#include "plstr.h"
#include "prinit.h"
#include "nsAutoLock.h"
#include "nsAutoPtr.h"
+#include "nsEmbedCID.h"
#include "mozStoragePrivateHelpers.h"
#include "sqlite3.h"
+#include "nsIPromptService.h"
+
NS_IMPL_THREADSAFE_ISUPPORTS1(mozStorageService, mozIStorageService)
mozStorageService *mozStorageService::gStorageService = nsnull;
mozStorageService *
mozStorageService::GetSingleton()
{
if (gStorageService) {
NS_ADDREF(gStorageService);
return gStorageService;
}
+ // Ensure that we are using the same version of SQLite that we compiled with
+ // or newer. Our configure check ensures we are using a new enough version
+ // at compile time.
+ if (SQLITE_VERSION_NUMBER > sqlite3_libversion_number()) {
+ nsCOMPtr<nsIPromptService> ps =
+ do_GetService(NS_PROMPTSERVICE_CONTRACTID);
+ if (ps) {
+ nsAutoString title, message;
+ title.AppendASCII("SQLite Version Error");
+ message.AppendASCII("The application has been updated, but your "
+ "version of SQLite is too old and the "
+ "application cannot run.");
+ (void)ps->Alert(nsnull, title.get(), message.get());
+ }
+ PR_Abort();
+ }
+
gStorageService = new mozStorageService();
if (gStorageService) {
NS_ADDREF(gStorageService);
if (NS_FAILED(gStorageService->Init()))
NS_RELEASE(gStorageService);
}
return gStorageService;