Skip to content

Use new(std::nothrow) to prevent crashes #7849

Closed
@mrengineer7777

Description

@mrengineer7777

Board

NA

Device Description

NA

Hardware Configuration

Arduino ESP32 Feather

Version

latest master (checkout manually)

IDE Name

PlatformIO

Operating System

Win11

Flash frequency

80Mhz

PSRAM enabled

no

Upload speed

115200

Description

I noticed in ESP8266 that they have changed their new calls to new(std::nothrow). This could prevent some crashes in our libraries.

See esp8266/Arduino@6925982

cbuf is one of the libraries that was fixed.

Sketch

#include "Arduino.h"
#include "cbuf.h"

void setup() {
    cbuf *p = new cbuf(128);
    p->resize(100);
}

void loop() {
}

Debug Message

Crash on low memory

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions