changeset 106:f6706f2aebbd

Fix a possible memory corruption issue in certain circumstances.
author Brian Smith <brian@dbsoft.org>
date Sat, 24 Aug 2013 13:40:44 -0500
parents e892ab8e2e42
children 172fd5a43b01
files src/handyftp.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/handyftp.c	Thu Dec 27 08:55:11 2012 -0600
+++ b/src/handyftp.c	Sat Aug 24 13:40:44 2013 -0500
@@ -6588,6 +6588,8 @@
 
 	if(validatecurrentpage())
 	{
+		char *oldcontexttext = contexttext;
+        
 		if(hwnd == site[currentpage]->ldir)
 		{
 			hwndMenu = dw_menu_new(0L);
@@ -6639,7 +6641,14 @@
 			}
 		}
 
-		contexttext = text;
+		/* Make a copy of the text for safety ...
+		 * since it may be freed when the row is removed
+		 * from the container control.
+		 */
+		contexttext = text ? strdup(text) : NULL;
+		/* Free the old memory */
+		if(oldcontexttext)
+			free(oldcontexttext);
 
 		dw_menu_item_set_state(hwndMenu, IDP_SORTF, abs(site[currentpage]->sort) == SORT_FILE ? DW_MIS_CHECKED : DW_MIS_UNCHECKED);
 		dw_menu_item_set_state(hwndMenu, IDP_SORTS, abs(site[currentpage]->sort) == SORT_SIZE ? DW_MIS_CHECKED : DW_MIS_UNCHECKED);