1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Abort if BearSSL stack allocation fails (#7152)

As found by @d-a-v, if the malloc() used to get the BearSSL stack does
not succeed, abort() immediately.
This commit is contained in:
Earle F. Philhower, III 2020-03-15 11:56:23 -07:00 committed by GitHub
parent e252873263
commit db75d2c448
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,6 +26,9 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include "pgmspace.h"
#include "debug.h"
#include "StackThunk.h"
#include <ets_sys.h>
@ -46,6 +49,11 @@ void stack_thunk_add_ref()
stack_thunk_refcnt++;
if (stack_thunk_refcnt == 1) {
stack_thunk_ptr = (uint32_t *)malloc(_stackSize * sizeof(uint32_t));
if (!stack_thunk_ptr) {
// This is a fatal error, stop the sketch
DEBUGV("Unable to allocate BearSSL stack\n");
abort();
}
stack_thunk_top = stack_thunk_ptr + _stackSize - 1;
stack_thunk_save = NULL;
stack_thunk_repaint();