mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 05:02:12 +00:00
531b014e7a
reallocarray() is a safer variant of realloc which checks for multiplication overflow in case of array allocation. Since it's not available in Glibc < 2.26 import kernel's overflow.h and add a static inline implementation when needed. Use feature detection to probe for existence of reallocarray. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com> Reviewed-by: Jiong Wang <jiong.wang@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
9 lines
132 B
C
9 lines
132 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#define _GNU_SOURCE
|
|
#include <stdlib.h>
|
|
|
|
int main(void)
|
|
{
|
|
return !!reallocarray(NULL, 1, 1);
|
|
}
|