8000 PID::PID() constructor dereferences uninitialized "myOutput" pointer · Issue #4 · br3ttb/Arduino-PID-Library · GitHub
[go: up one dir, main page]

Skip to content
PID::PID() constructor dereferences uninitialized "myOutput" pointer #4
@Voltara

Description

@Voltara

The PID::PID() constructor prematurely accesses uninitialized members, which can potentially dereference an uninitialized pointer (this causes a Segmentation Fault when testing locally on my Linux box.)

  PID::PID(double* Input, double* Output, double* Setpoint,
          double Kp, double Ki, double Kd, int ControllerDirection)
  {
          PID::SetOutputLimits(0, 255);                           //default output limit corresponds to 

The SetOutputLimits() method depends on members "inAuto" "myOutput" and "ITerm", which have not yet been initialized by the time it is called by the constructor. If "inAuto" (uninitialized) happens to be true, SetOutputLimits() will read+write to a random memory location via the uninitialized pointer "myOutput".

The call to PID::SetControllerDirection() also prematurely accesses uninitialized members, but that appears to be harmless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0