mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 14:48:10 +02:00
ifupdown: avoid calloc()
It can return NULL and makes Coverity upset: CID 75369 (#1 of 1): Dereference null return value (NULL_RETURNS) 4. dereference: Dereferencing a null pointer ret.
This commit is contained in:
parent
2e563d9c84
commit
76844c65d6
1 changed files with 8 additions and 8 deletions
|
|
@ -39,7 +39,7 @@ if_data* last_data;
|
||||||
|
|
||||||
void add_block(const char *type, const char* name)
|
void add_block(const char *type, const char* name)
|
||||||
{
|
{
|
||||||
if_block *ret = (if_block*)calloc(1,sizeof(struct _if_block));
|
if_block *ret = g_slice_new0 (struct _if_block);
|
||||||
ret->name = g_strdup(name);
|
ret->name = g_strdup(name);
|
||||||
ret->type = g_strdup(type);
|
ret->type = g_strdup(type);
|
||||||
if (first == NULL)
|
if (first == NULL)
|
||||||
|
|
@ -61,7 +61,7 @@ void add_data(const char *key,const char *data)
|
||||||
if (first == NULL)
|
if (first == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ret = (if_data*) calloc(1,sizeof(struct _if_data));
|
ret = g_slice_new0 (struct _if_data);
|
||||||
ret->key = g_strdup(key);
|
ret->key = g_strdup(key);
|
||||||
|
|
||||||
/* Normalize keys. Convert '_' to '-', as ifupdown accepts both variants.
|
/* Normalize keys. Convert '_' to '-', as ifupdown accepts both variants.
|
||||||
|
|
@ -298,9 +298,9 @@ void _destroy_data(if_data *ifd)
|
||||||
if (ifd == NULL)
|
if (ifd == NULL)
|
||||||
return;
|
return;
|
||||||
_destroy_data(ifd->next);
|
_destroy_data(ifd->next);
|
||||||
free(ifd->key);
|
g_free(ifd->key);
|
||||||
free(ifd->data);
|
g_free(ifd->data);
|
||||||
free(ifd);
|
g_slice_free(struct _if_data, ifd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -310,9 +310,9 @@ void _destroy_block(if_block* ifb)
|
||||||
return;
|
return;
|
||||||
_destroy_block(ifb->next);
|
_destroy_block(ifb->next);
|
||||||
_destroy_data(ifb->info);
|
_destroy_data(ifb->info);
|
||||||
free(ifb->name);
|
g_free(ifb->name);
|
||||||
free(ifb->type);
|
g_free(ifb->type);
|
||||||
free(ifb);
|
g_slice_free(struct _if_block, ifb);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue