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

Fixed a bug in list_to_binary #691

Merged
merged 1 commit into from
Jul 19, 2023
Merged

Conversation

fadushin
Copy link
Collaborator

malloc(0) returns NULL on ESP32, which results in an OUT_OF_MEMORY error. This PR checks handles the case where the size of the input list is 0 specially.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

@pguyot
Copy link
Collaborator

pguyot commented Jul 18, 2023

Sorry. Does the problem occur on generic unix? If it only occurs on ESP32 we may want to have an ESP32 test instead.

@bettio
Copy link
Collaborator

bettio commented Jul 18, 2023

Sorry. Does the problem occur on generic unix? If it only occurs on ESP32 we may want to have an ESP32 test instead.

glibc man page says:

NULL  may
also  be returned by a successful call to malloc() with a size of zero, or by a successful
call to calloc() with nmemb or size equal to zero.

src/libAtomVM/term.h Outdated Show resolved Hide resolved
@fadushin fadushin merged commit f12446d into atomvm:master Jul 19, 2023
83 checks passed
@fadushin fadushin deleted the list_to_binary-fix branch July 19, 2023 12:14
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.

3 participants