Skip to contentSkip to conversation

lxc-user-nic: fix the wrong use of realloc

PATCH In review Libo Chen 2 participants 2 messages Dec 13, 2013 1 message not in the archive

lore
Share & tools
lore

Libo Chen

author
#0 lore raw

PATCH 1/1 lxc-user-nic: fix the wrong use of realloc

fix the wrong use of realloc

---
 src/lxc/lxc_user_nic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/lxc/lxc_user_nic.c +1 -1
index caa411a..ac7a242 100644
@@ -318,7 +318,7 @@ static bool cull_entries(int fd, char *me, char *t, char *br)
 	p = buf;
 	e = buf + len;
 	while ((p = find_line(p, e, me, t, br)) != NULL) {
-		struct entry_line *newe = realloc(entry_lines, n+1);
+		struct entry_line *newe = realloc(entry_lines, sizeof(*entry_lines)*(n+1));
 		if (!newe) {
 			free(entry_lines);
 			return false;
Signature · 1 line
1.8.2.2

A message that is not in the archive (sent off-list or not yet received): [email protected]

Acked-by
#2 lore raw
Quoted 3 lines · Libo Chen

fix the wrong use of realloc

Embarassing. Thanks.

Quoted 20 lines
---
 src/lxc/lxc_user_nic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/lxc/lxc_user_nic.c +1 -1
index caa411a..ac7a242 100644
@@ -318,7 +318,7 @@ static bool cull_entries(int fd, char *me, char *t, char *br)
 	p = buf;
 	e = buf + len;
 	while ((p = find_line(p, e, me, t, br)) != NULL) {
-		struct entry_line *newe = realloc(entry_lines, n+1);
+		struct entry_line *newe = realloc(entry_lines, sizeof(*entry_lines)*(n+1));
 		if (!newe) {
 			free(entry_lines);
 			return false;
Signature · 1 line
1.8.2.2