Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#77 Fix double-freeing memory #24

Merged
merged 1 commit into from
Sep 16, 2021

Conversation

ooxi
Copy link
Contributor

@ooxi ooxi commented Sep 16, 2021

@efo applied #77 Fix double-freeing memory as opening 2nd or 3th .gvp file on Windows crash

See SourceForge patch #77 by Hiroshi Yoshikawa


I created a patch for #256 Memory Double-Free Problem.
Crash with exception 0xc0000374 or freezing windows symptom will disappear by this patch.

diff -uprN a/src/callbacks.c b/src/callbacks.c
--- a/src/callbacks.c	2019-01-22 18:01:00.000000000 +0900
+++ b/src/callbacks.c	2020-10-25 11:41:24.592107000 +0900
@@ -199,7 +199,7 @@ void open_project(char *project_filename
 
 	/* Update the last folder */
 	g_free (mainProject->path);
-	mainProject->path = project_filename;
+	mainProject->path = g_strdup(project_filename);
 
 	gerbv_unload_all_layers (mainProject);
 	main_open_project_from_filename (mainProject, project_filename);
@@ -2768,7 +2768,7 @@ callbacks_file_drop_event(GtkWidget *wid
 	}
 
 	open_files(fns);
-	g_slist_free(fns);
+	g_slist_free_full(fns, g_free);
 	g_strfreev(uris);
 
 	return TRUE;
diff -uprN a/src/gerb_file.c b/src/gerb_file.c
--- a/src/gerb_file.c	2019-01-22 18:01:00.000000000 +0900
+++ b/src/gerb_file.c	2020-10-25 11:46:47.041550000 +0900
@@ -108,7 +108,7 @@ gerb_fopen(char const * filename)
     }
 #else
     /* all systems without mmap, not only MINGW32 */
-    fd = g_new(gerb_file_t);
+    fd = g_new(gerb_file_t, 1);
     if (fd == NULL) {
 	return NULL;
     }

@ooxi ooxi marked this pull request as ready for review September 16, 2021 09:56
@ooxi ooxi merged commit a96b46c into gerbv:main Sep 16, 2021
@ooxi ooxi deleted the patch/77-fix-double-freeing-memory branch September 16, 2021 09:56
@ooxi ooxi mentioned this pull request Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants