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
|
@ -85,6 +85,18 @@ grub_util_error (const char *fmt, ...)
|
|||
exit (1);
|
||||
}
|
||||
|
||||
void *
|
||||
xcalloc (grub_size_t nmemb, grub_size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = calloc (nmemb, size);
|
||||
if (!p)
|
||||
grub_util_error ("%s", _("out of memory"));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void *
|
||||
xmalloc (grub_size_t size)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue