Skip to content

Conversation

@cj-vana
Copy link

@cj-vana cj-vana commented Jan 4, 2026

Summary

Add null safety checks after new operations for PMU initialization in TBeamBoard.cpp.

Changes

  • Check if new XPowersAXP2101() succeeded before calling init()
  • Check if new XPowersAXP192() succeeded before calling init()

Why

In embedded systems with limited RAM, new can fail and return nullptr. Dereferencing nullptr causes a crash. This adds defensive null checks to prevent potential crashes.

// Before
if (!PMU->init()) {

// After  
if (!PMU || !PMU->init()) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant