Menu

#28 Free Null pointer on CU_destroy_existing_registry()

Unstable_(example)
open
nobody
segfault (1)
1
2022-03-25
2022-03-25
Anonymous
No

Hello,

in function CU_destroy_existing_registry()

void CU_destroy_existing_registry(CU_pTestRegistry* ppRegistry)
{
  assert(NULL != ppRegistry);

  /* Note - CU_cleanup_registry counts on being able to pass NULL */

  if (NULL != *ppRegistry) {
    cleanup_test_registry(*ppRegistry);
  }
  CU_FREE(*ppRegistry);
  *ppRegistry = NULL;
}

the CU_FREE is called even if the ppRegistry is NULL (outside the if)
so, could be better to execute the CU_FREE inside the if
(i got segfault on my code due to NULL pointer free at this very point)

Best Regards,

1 Attachments

Discussion

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.