Skip to content

Commit

Permalink
Fix null pointer argument (#4602)
Browse files Browse the repository at this point in the history
ubsan doesn't like it when a null pointer is passed to memcpy. this
commit fixes things to make ubsan happy.

Makes ubsan runtime errors such as the following go away:

`runtime error: null pointer passed as argument 2, which is declared to never be null`
  • Loading branch information
dipinhora authored Feb 6, 2025
1 parent 23d046e commit 0bbf613
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libponyc/reach/reach.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ static void add_rmethod_to_subtype(reach_t* r, reach_type_t* t,
mangled->param_count = m->param_count;
mangled->params = (reach_param_t*)ponyint_pool_alloc_size(
mangled->param_count * sizeof(reach_param_t));
memcpy(mangled->params, m->params, m->param_count * sizeof(reach_param_t));
if(m->param_count > 0)
memcpy(mangled->params, m->params, m->param_count * sizeof(reach_param_t));
mangled->result = m->result;

// Add to the mangled table only.
Expand Down

0 comments on commit 0bbf613

Please sign in to comment.