Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abort if BearSSL stack allocation fails #7152

Merged
merged 2 commits into from
Mar 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cores/esp8266/StackThunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand All @@ -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();
Expand Down