From 3d79c9965851605fc46a040f4e1a43f4d9de980d Mon Sep 17 00:00:00 2001 From: kcwu Date: Tue, 19 Apr 2005 18:07:48 +0000 Subject: add assertion. deallocate resources. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2698 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/fav.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mbbsd/fav.c') diff --git a/mbbsd/fav.c b/mbbsd/fav.c index 0c627660..9a658efd 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -1056,6 +1056,7 @@ void updatenewfav(int mode) if( (fd = open(fname, O_RDWR | O_CREAT, 0600)) != -1 ){ + assert(numboards>=0); brdnum = numboards; /* avoid race */ brd = (char *)malloc((brdnum + 1) * sizeof(char)); @@ -1063,6 +1064,8 @@ void updatenewfav(int mode) i = read(fd, brd, (brdnum + 1) * sizeof(char)); if (i < 0) { + free(brd); + close(fd); vmsg("favorite subscription error"); return; } -- cgit v1.2.3