Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3634a1e3 authored by Felipe Leme's avatar Felipe Leme
Browse files

Fixed logic that was passing NULL to a std::string parameter and

crashing dumpstate.

BUG: 8420215
Change-Id: If2f3ebad559683b5b6a8c2209de93ac3bec4fb1e
parent e338bf60
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ static unsigned long logcat_timeout(const char *name) {
/* End copy from system/core/logd/LogBuffer.cpp */

/* dumps the current system state to stdout */
static void dumpstate(std::string screenshot_path) {
static void dumpstate(const std::string& screenshot_path) {
    unsigned long timeout;
    time_t now = time(NULL);
    char build[PROPERTY_VALUE_MAX], fingerprint[PROPERTY_VALUE_MAX];
@@ -815,7 +815,11 @@ int main(int argc, char *argv[]) {
        }
    }

    if (!screenshot_path.empty() && do_early_screenshot) {
    if (do_fb && do_early_screenshot) {
        if (screenshot_path.empty()) {
            // should not have happened
            ALOGE("INTERNAL ERROR: skipping early screenshot because path was not set");
        } else {
            ALOGI("taking early screenshot\n");
            take_screenshot(screenshot_path);
            ALOGI("wrote screenshot: %s\n", screenshot_path.c_str());
@@ -824,6 +828,7 @@ int main(int argc, char *argv[]) {
                        screenshot_path.c_str(), strerror(errno));
            }
        }
    }

    /* read /proc/cmdline before dropping root */
    FILE *cmdline = fopen("/proc/cmdline", "re");
@@ -884,7 +889,7 @@ int main(int argc, char *argv[]) {
        redirect_to_file(stdout, const_cast<char*>(tmp_path.c_str()));
    }

    dumpstate(do_early_screenshot ? NULL : screenshot_path);
    dumpstate(do_early_screenshot ? "": screenshot_path);

    /* done */
    if (vibrator) {
+1 −1
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ void play_sound(const char *path);
void dumpstate_board();

/* Takes a screenshot and save it to the given file */
void take_screenshot(std::string path);
void take_screenshot(const std::string& path);

#ifdef __cplusplus
}
+1 −1
Original line number Diff line number Diff line
@@ -880,7 +880,7 @@ void update_progress(int delta) {
    }
}

void take_screenshot(std::string path) {
void take_screenshot(const std::string& path) {
    const char *args[] = { "/system/bin/screencap", "-p", path.c_str(), NULL };
    run_command_always(NULL, 10, args);
}