diff options
author | FreeArtMan <dos21h@gmail.com> | 2015-01-13 02:02:03 +0900 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2015-01-13 02:02:03 +0900 |
commit | 4985e5e287683b16ff46c2b3069388f11bcb5698 (patch) | |
tree | 938ff091840e3d4423b49547d2f314da48c0be07 /door.c | |
parent | 3069d0048c860e16a4bd6866ae2841a7ddd74628 (diff) | |
download | microbbs-4985e5e287683b16ff46c2b3069388f11bcb5698.tar.gz microbbs-4985e5e287683b16ff46c2b3069388f11bcb5698.zip |
Fixed memleaks in door and user auth
Diffstat (limited to 'door.c')
-rw-r--r-- | door.c | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -10,6 +10,7 @@ static int dir_door_game_selector (const struct dirent *unused) return 1; } + int bbs_door_start( term_screen *ts, const char *cmd ) { int ret=0; @@ -86,7 +87,8 @@ int bbs_door( term_screen *ts, const char *dir_name ) { sds d_name = sds_new( eps[cnt]->d_name ); sds pathname = sds_new( door_game_dir ); - sds_cat( pathname, d_name ); + pathname = sds_cat( pathname, d_name ); + sds_free( d_name ); //!!!possible memleak unfreed d_name? @@ -100,12 +102,10 @@ int bbs_door( term_screen *ts, const char *dir_name ) } else { sds_free( pathname ); - sds_free( d_name ); } } else { sds_free( pathname ); - sds_free( d_name ); } free( eps[cnt] ); } @@ -199,7 +199,22 @@ int bbs_door( term_screen *ts, const char *dir_name ) } //needed special care to free sds strings - //llist_free( dir_list ); + //dangerous stuff as list contains sds strings then we need to call sds_free + //not just free, maybe try to use llist_manager it should handle that + { + struct ListNode *iter=dir_list->first; + while (iter != NULL) + { + if ( iter->val != NULL ) + { + sds_free( iter->val ); + iter->val = NULL; + } + iter = iter->next; + } + + } + llist_free( dir_list ); return ret; } |