diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-27 23:29:41 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-27 23:29:41 +0800 |
commit | d41c5d3f5d6c34b037b0ccaa7b098c838d068f9c (patch) | |
tree | 89b43999722de5f41afd475d7c497bec6586a9af /mbbsd | |
parent | e5c3a9899bc3d11d3b4bf84058fc6f259cfab807 (diff) | |
download | pttbbs-d41c5d3f5d6c34b037b0ccaa7b098c838d068f9c.tar pttbbs-d41c5d3f5d6c34b037b0ccaa7b098c838d068f9c.tar.gz pttbbs-d41c5d3f5d6c34b037b0ccaa7b098c838d068f9c.tar.bz2 pttbbs-d41c5d3f5d6c34b037b0ccaa7b098c838d068f9c.tar.lz pttbbs-d41c5d3f5d6c34b037b0ccaa7b098c838d068f9c.tar.xz pttbbs-d41c5d3f5d6c34b037b0ccaa7b098c838d068f9c.tar.zst pttbbs-d41c5d3f5d6c34b037b0ccaa7b098c838d068f9c.zip |
fix heap corrupted because screen resize.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3089 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/announce.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/mbbsd/announce.c b/mbbsd/announce.c index 72a5fe8c..1115fba8 100644 --- a/mbbsd/announce.c +++ b/mbbsd/announce.c @@ -161,15 +161,21 @@ a_copyitem(const char *fpath, const char *title, const char *owner, int mode) #define FHSZ sizeof(fileheader_t) static void -a_loadname(const menu_t * pm) +a_loadname(menu_t * pm) { char buf[PATHLEN]; int len; + if(p_lines != pm->header_size) { + pm->header_size = p_lines; + pm->header = (fileheader_t *) realloc(pm->header, pm->header_size*FHSZ); + assert(pm->header); + } + setadir(buf, pm->path); - len = get_records(buf, pm->header, FHSZ, pm->page + 1, p_lines); - if (len < p_lines) - bzero(&pm->header[len], FHSZ * (p_lines - len)); + len = get_records(buf, pm->header, FHSZ, pm->page + 1, pm->header_size); + if (len < pm->header_size) + bzero(&pm->header[len], FHSZ * (pm->header_size - len)); } static void @@ -181,7 +187,7 @@ a_timestamp(char *buf, const time4_t *time) } static void -a_showmenu(const menu_t * pm) +a_showmenu(menu_t * pm) { char *title, *editor; int n; @@ -922,7 +928,8 @@ a_menu(const char *maintitle, const char *path, int lastlevel, char *trans_buffe trans_buffer[0] = '\0'; Fexit = 0; - me.header = (fileheader_t *) calloc(p_lines, FHSZ); + me.header_size = p_lines; + me.header = (fileheader_t *) calloc(me.header_size, FHSZ); me.path = path; strlcpy(me.mtitle, maintitle, sizeof(me.mtitle)); setadir(fname, me.path); @@ -944,7 +951,7 @@ a_menu(const char *maintitle, const char *path, int lastlevel, char *trans_buffe if (me.now < 0) me.now = 0; - if (me.now < me.page || me.now >= me.page + p_lines) { + if (me.now < me.page || me.now >= me.page + me.header_size) { me.page = me.now - ((me.page == 10000 && me.now > p_lines / 2) ? (p_lines / 2) : (me.now % p_lines)); a_showmenu(&me); @@ -1119,8 +1126,8 @@ a_menu(const char *maintitle, const char *path, int lastlevel, char *trans_buffe me.now = me.num - 1; break; } - /* we only load p_lines pages */ - if (me.now - me.page >= p_lines) + /* we only load me.header_size pages */ + if (me.now - me.page >= me.header_size) break; } else break; |