Add error check for GetCurrentSlot am: 1815c4dd52

Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/2820039

Change-Id: I601e159bad36bac5459b9de1304a0b301f8a3bf6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index d7cb2d2..ea83d9a 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -638,6 +638,14 @@
   ErrorCode errorcode{};
 
   BootControlInterface::Slot current_slot = GetCurrentSlot();
+  if (current_slot < 0) {
+    return LogAndSetError(
+        error,
+        __LINE__,
+        __FILE__,
+        "Failed to get current slot " + std::to_string(current_slot),
+        ErrorCode::kDownloadStateInitializationError);
+  }
   for (const PartitionUpdate& partition : manifest.partitions()) {
     if (!partition.has_old_partition_info())
       continue;