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

Commit 88dbf655 authored by George Burgess's avatar George Burgess Committed by Android (Google) Code Review
Browse files

Merge "fix potential use-after-frees of stack memory"

parents dce19ea7 f2493a3c
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -21,18 +21,17 @@ namespace hardware {
namespace gnss {
namespace common {

const char* ReplayUtils::getGnssPath() {
    const char* gnss_dev_path = GNSS_PATH;
std::string ReplayUtils::getGnssPath() {
    char devname_value[PROPERTY_VALUE_MAX] = "";
    if (property_get("debug.location.gnss.devname", devname_value, NULL) > 0) {
        gnss_dev_path = devname_value;
        return devname_value;
    }
    return gnss_dev_path;
    return GNSS_PATH;
}

bool ReplayUtils::hasGnssDeviceFile() {
    struct stat sb;
    return stat(getGnssPath(), &sb) != -1;
    return stat(getGnssPath().c_str(), &sb) != -1;
}

bool ReplayUtils::isGnssRawMeasurement(const std::string& inputStr) {
@@ -47,7 +46,7 @@ bool ReplayUtils::isNMEA(const std::string& inputStr) {

std::string ReplayUtils::getDataFromDeviceFile(const std::string& command, int mMinIntervalMs) {
    char inputBuffer[INPUT_BUFFER_SIZE];
    int mGnssFd = open(getGnssPath(), O_RDWR | O_NONBLOCK);
    int mGnssFd = open(getGnssPath().c_str(), O_RDWR | O_NONBLOCK);

    if (mGnssFd == -1) {
        return "";
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ namespace gnss {
namespace common {

struct ReplayUtils {
    static const char* getGnssPath();
    static std::string getGnssPath();

    static std::string getDataFromDeviceFile(const std::string& command, int mMinIntervalMs);

+3 −3
Original line number Diff line number Diff line
@@ -161,11 +161,11 @@ template <class T_IGnss>
std::unique_ptr<V2_0::GnssLocation> GnssTemplate<T_IGnss>::getLocationFromHW() {
    if (!mHardwareModeChecked) {
        // default using /dev/gnss0
        const char* gnss_dev_path = ReplayUtils::getGnssPath();
        std::string gnss_dev_path = ReplayUtils::getGnssPath();

        mGnssFd = open(gnss_dev_path, O_RDWR | O_NONBLOCK);
        mGnssFd = open(gnss_dev_path.c_str(), O_RDWR | O_NONBLOCK);
        if (mGnssFd == -1) {
            ALOGW("Failed to open %s errno: %d", gnss_dev_path, errno);
            ALOGW("Failed to open %s errno: %d", gnss_dev_path.c_str(), errno);
        }
        mHardwareModeChecked = true;
    }