diff options
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; } |