Merge "Handle error from fopen_path in finish_recovery" am: 8a4333f3b9 am: a550ee0df7 am: b33a6f8342
am: d38ddde181

Change-Id: I8f21fc8895f5bc2bb714ce64aad137052e825464
diff --git a/recovery.cpp b/recovery.cpp
index cfca9df..725976f 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -526,10 +526,12 @@
         if (has_cache) {
             LOGI("Saving locale \"%s\"\n", locale);
             FILE* fp = fopen_path(LOCALE_FILE, "w");
-            fwrite(locale, 1, len, fp);
-            fflush(fp);
-            fsync(fileno(fp));
-            check_and_fclose(fp, LOCALE_FILE);
+            if (fp != NULL) {
+                fwrite(locale, 1, len, fp);
+                fflush(fp);
+                fsync(fileno(fp));
+                check_and_fclose(fp, LOCALE_FILE);
+            }
         }
     }