diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 15dcb9c..efac56e 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -926,7 +926,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
 function variable_initialize($conf = array()) {
   // NOTE: caching the variables improves performance by 20% when serving
   // cached pages.
-  if ($cached = cache_get('variables', 'cache_bootstrap')) {
+  if (($cached = cache_get('variables', 'cache_bootstrap')) && !empty($cached->data)) {
     $variables = $cached->data;
   }
   else {
@@ -941,8 +941,16 @@ function variable_initialize($conf = array()) {
     else {
       // Proceed with variable rebuild.
       $variables = array_map('unserialize', db_query('SELECT name, value FROM {variable}')->fetchAllKeyed());
-      cache_set('variables', $variables, 'cache_bootstrap');
-      lock_release($name);
+      if (!empty($variables)) {
+        cache_set('variables', $variables, 'cache_bootstrap');
+        lock_release($name);
+      }
+      else {
+        // Prevent this request from harming anything due to default variable values.
+        lock_release($name);
+        drupal_set_header($_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error');
+        exit;
+      }
     }
   }
 
