Skip to content

Bad free() in begin() #12

@Blake-Ballew

Description

@Blake-Ballew

Hi all,

I'm experiencing crashes attempting to initialize an LSM303AGR compass. This crash occurs during begin() and seems to be due to
an uninitialized pointer being deleted on line 71 of Adafruit_LSM303_Accel.cpp. begin() seems to work fine if i2c_dev is initialized to NULL.

Code:

    LSM303AGR()
    {
        #if DEBUG == 1
        Serial.println("Compass LSM303AGR::LSM303AGR: Initializing");
        #endif

        if (!_CompassMagnetometer.begin())
        {
            Serial.println("Compass LSM303AGR::LSM303AGR: Magnetometer not found");
        }

        #if DEBUG == 1
        Serial.println("_CompassMagnetometer Initialized");
        #endif

        if (!_CompassAccelerometer.begin())
        {
            Serial.println("Compass LSM303AGR::LSM303AGR: Accelerometer not found");
        }

        Serial.println("Compass LSM303AGR::LSM303AGR: Initialized");
    }
  • Arduino board: ESP32-WROOM-32E(16MB)

  • Arduino IDE version (found in Arduino -> About Arduino menu): arduino-esp32 2.0.16 in platformio

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):

  • Create Adafruit_LSM303_Accel_Unified object

  • Program crashes upon accel.begin() for using a bad free().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions