Commit 342d81db authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(copy_membership): Don't allocate a copy of read_ranges if read_ranges

	is NULL.
parent 4e96380f
/*
* $Id: memory.c,v 0.44 2003/01/12 19:56:17 ceder Exp $
* $Id: memory.c,v 0.45 2003/03/23 22:02:12 ceder Exp $
* Copyright (C) 1991-1994, 1996-1999, 2001-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -285,9 +285,19 @@ copy_membership(Membership m)
Membership res;
res = m;
res.read_ranges = smalloc(m.no_of_read_ranges*sizeof(res.read_ranges[0]));
memcpy(res.read_ranges, m.read_ranges,
m.no_of_read_ranges * sizeof(res.read_ranges[0]));
if (m.no_of_read_ranges != 0)
{
res.read_ranges = smalloc(m.no_of_read_ranges
* sizeof(res.read_ranges[0]));
memcpy(res.read_ranges, m.read_ranges,
m.no_of_read_ranges * sizeof(res.read_ranges[0]));
}
else if (m.read_ranges != NULL)
{
kom_log("copy_membership(): "
"read_ranges != NULL but no_of_read_ranges == 0\n");
res.read_ranges = NULL;
}
return res;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment