calloc: Make sure we always have an overflow-checking calloc() available
This tries to make sure that everywhere in this source tree, we always have an appropriate version of calloc() (i.e. grub_calloc(), xcalloc(), etc.) available, and that they all safely check for overflow and return NULL when it would occur. Signed-off-by: Peter Jones <pjones@redhat.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
68708c4503
commit
64e26162eb
7 changed files with 85 additions and 3 deletions
|
@ -25,6 +25,16 @@
|
|||
#include <string.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
void *
|
||||
grub_calloc (grub_size_t nmemb, grub_size_t size)
|
||||
{
|
||||
void *ret;
|
||||
ret = calloc (nmemb, size);
|
||||
if (!ret)
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *
|
||||
grub_malloc (grub_size_t size)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue