summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2016-04-28 17:48:58 +0200
committerLubomir Rintel <lkundrak@v3.sk>2016-04-29 12:47:34 +0200
commit76844c65d6c8ffb5a5b8f5ede3fceada7de9a5da (patch)
treeb804d1d4d54e23dd85876ae8e06175a41c2bb440
parent2e563d9c842cda076413c62fe9cd96c58705ea47 (diff)
downloadNetworkManager-76844c65d6c8ffb5a5b8f5ede3fceada7de9a5da.tar.gz
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.
-rw-r--r--src/settings/plugins/ifupdown/interface_parser.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/settings/plugins/ifupdown/interface_parser.c b/src/settings/plugins/ifupdown/interface_parser.c
index d342501b28..7ad902d427 100644
--- a/src/settings/plugins/ifupdown/interface_parser.c
+++ b/src/settings/plugins/ifupdown/interface_parser.c
@@ -39,7 +39,7 @@ if_data* last_data;
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->type = g_strdup(type);
if (first == NULL)
@@ -61,7 +61,7 @@ void add_data(const char *key,const char *data)
if (first == NULL)
return;
- ret = (if_data*) calloc(1,sizeof(struct _if_data));
+ ret = g_slice_new0 (struct _if_data);
ret->key = g_strdup(key);
/* Normalize keys. Convert '_' to '-', as ifupdown accepts both variants.
@@ -298,9 +298,9 @@ void _destroy_data(if_data *ifd)
if (ifd == NULL)
return;
_destroy_data(ifd->next);
- free(ifd->key);
- free(ifd->data);
- free(ifd);
+ g_free(ifd->key);
+ g_free(ifd->data);
+ g_slice_free(struct _if_data, ifd);
return;
}
@@ -310,9 +310,9 @@ void _destroy_block(if_block* ifb)
return;
_destroy_block(ifb->next);
_destroy_data(ifb->info);
- free(ifb->name);
- free(ifb->type);
- free(ifb);
+ g_free(ifb->name);
+ g_free(ifb->type);
+ g_slice_free(struct _if_block, ifb);
return;
}