diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-06-13 15:16:51 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-06-13 15:16:51 +0000 |
commit | 7dd13c465706d284f06d9716b09b467e424c8f28 (patch) | |
tree | 9e98bc4f39a845f6b8d850399a43631ac8dfd649 /usr.sbin/bgpd | |
parent | 13356baba7c3cc35d3bc28e2d0677828ea7aa158 (diff) |
realloc(3) correctly. Do not adjust the variable describing how much memory
has been allocated until one knows the allocation has been successful.
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/rde_attr.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/rde_attr.c b/usr.sbin/bgpd/rde_attr.c index 1547d926572..1f608ee55a2 100644 --- a/usr.sbin/bgpd/rde_attr.c +++ b/usr.sbin/bgpd/rde_attr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_attr.c,v 1.48 2005/06/10 10:02:21 claudio Exp $ */ +/* $OpenBSD: rde_attr.c,v 1.49 2005/06/13 15:16:50 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -703,11 +703,12 @@ community_set(struct attr *attr, int as, int type) if (i >= ncommunities) { if (attr->len > 0xffff - 4) /* overflow */ return (0); - attr->len += 4; - if ((p = realloc(attr->data, attr->len)) == NULL) + i = attr->len + 4; + if ((p = realloc(attr->data, i)) == NULL) return (0); attr->data = p; + attr->len = i; p = attr->data + attr->len - 4; } p[0] = as >> 8; |