[HUST CSE][rp2_common][pico_malloc.c]Modify to check if rc is a null pointer #1399

Closed
jming912 wants to merge 1 commit from develop into develop
jming912 commented 2023-05-26 23:18:22 -05:00 (Migrated from github.com)
The code on lines 41, 58, and 75 of this code may attempt to convert a null pointer to a uint8_t* type and attempt to perform an addition operation on top of that pointer. This behavior is undefined, and the undefined result depends on the specific compiler and runtime environment. In some cases, this may cause the program to crash.
In this modified version, we first check if rc is NULL. if rc is NULL, we print a message stating that calloc failed to allocate the required memory. Only if rc is not NULL do we attempt pointer arithmetic and proceed to the next conditional step. This avoids undefined pointer operations when rc is NULL.
The issue of this pr is Fixes #1397 
The code on lines 41, 58, and 75 of this code may attempt to convert a null pointer to a uint8_t* type and attempt to perform an addition operation on top of that pointer. This behavior is undefined, and the undefined result depends on the specific compiler and runtime environment. In some cases, this may cause the program to crash. In this modified version, we first check if rc is NULL. if rc is NULL, we print a message stating that calloc failed to allocate the required memory. Only if rc is not NULL do we attempt pointer arithmetic and proceed to the next conditional step. This avoids undefined pointer operations when rc is NULL. The issue of this pr is Fixes #1397
kilograham commented 2023-05-27 10:00:00 -05:00 (Migrated from github.com)

fixes #1397

fixes #1397
jming912 commented 2023-05-28 20:24:50 -05:00 (Migrated from github.com)

fixes #1397

Could you approve my workflow

> fixes #1397 Could you approve my workflow
kilograham commented 2023-05-30 16:54:38 -05:00 (Migrated from github.com)

nope; please comment on the associated issue as to what circumstances this could ever be a problem.

nope; please comment on the associated issue as to what circumstances this could ever be a problem.
kilograham commented 2024-05-19 15:11:28 -05:00 (Migrated from github.com)

can you please fix code style to match

can you please fix code style to match
peterharperuk commented 2024-08-09 07:11:33 -05:00 (Migrated from github.com)

I think this fix has now been implemented. Thanks.

I think this fix has now been implemented. Thanks.

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk!1399
No description provided.