From 9914284d6afb1734747940de2c466f67078e4365 Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Fri, 19 Aug 2016 15:36:24 -0700 Subject: [PATCH] DO NOT MERGE: Fix bug in product path building -p was failing to find the product image files since get_my_path's result was ignored. As it was, it would only work if you happened to call it from $OUT. Change-Id: Id4183cb7fafb313c0b1feff93d7e22fd4658d267 Bug: 31022767 --- fastboot/fastboot.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index c1c317485..2b6cad101 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -116,16 +116,18 @@ static struct { }; static std::string find_item_given_name(const char* img_name, const char* product) { - char *dir; - char path[PATH_MAX + 128]; + char path_c_str[PATH_MAX + 128]; if(product) { - get_my_path(path); - return android::base::StringPrintf("../../../target/product/%s/%s", product, img_name); + get_my_path(path_c_str); + std::string path = path_c_str; + path.erase(path.find_last_of('/')); + return android::base::StringPrintf("%s/../../../target/product/%s/%s", + path.c_str(), product, img_name); } - dir = getenv("ANDROID_PRODUCT_OUT"); - if((dir == 0) || (dir[0] == 0)) { + char *dir = getenv("ANDROID_PRODUCT_OUT"); + if (dir == nullptr || dir[0] == '\0') { die("neither -p product specified nor ANDROID_PRODUCT_OUT set"); }