summaryrefslogtreecommitdiffstats
path: root/mbbsd/fav.c
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-04-20 02:07:48 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-04-20 02:07:48 +0800
commit3d79c9965851605fc46a040f4e1a43f4d9de980d (patch)
tree555528a14c927614aabea2757235a589eb377882 /mbbsd/fav.c
parentd9268ea3021f7112244a894a33882edcc408bf1a (diff)
downloadpttbbs-3d79c9965851605fc46a040f4e1a43f4d9de980d.tar
pttbbs-3d79c9965851605fc46a040f4e1a43f4d9de980d.tar.gz
pttbbs-3d79c9965851605fc46a040f4e1a43f4d9de980d.tar.bz2
pttbbs-3d79c9965851605fc46a040f4e1a43f4d9de980d.tar.lz
pttbbs-3d79c9965851605fc46a040f4e1a43f4d9de980d.tar.xz
pttbbs-3d79c9965851605fc46a040f4e1a43f4d9de980d.tar.zst
pttbbs-3d79c9965851605fc46a040f4e1a43f4d9de980d.zip
add assertion. deallocate resources.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2698 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/fav.c')
-rw-r--r--mbbsd/fav.c3
1 files changed, 3 insertions, 0 deletions
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;
}