Skip to content
Snippets Groups Projects
Commit 478478de authored by Eduardo Silva's avatar Eduardo Silva
Browse files

in_mem: add missing memory allocation validation (#1625)

parent ccef9217
No related branches found
No related tags found
No related merge requests found
......@@ -29,11 +29,17 @@
static char *human_readable_size(long size)
{
long u = 1024, i, len = 128;
char *buf = flb_malloc(len);
char *buf;
static const char *__units[] = { "b", "K", "M", "G",
"T", "P", "E", "Z", "Y", NULL
};
buf = flb_malloc(len);
if (!buf) {
flb_errno();
return NULL;
}
for (i = 0; __units[i] != NULL; i++) {
if ((size / u) == 0) {
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment