From 5949b7855aff36e7e084d7f2c15b62575b258171 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 9 Oct 2024 03:05:33 +0200 Subject: [PATCH] csharpcomp: Fix memory management bug (regression yesterday). * lib/csharpcomp.c (compile_csharp_using_sscli): Allocate the source options with malloc() always, not sometimes with malloca() and sometimes with malloc(). --- ChangeLog | 7 +++++++ lib/csharpcomp.c | 9 +++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 27e1dca18c..1ddf1e11b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-10-08 Bruno Haible + + csharpcomp: Fix memory management bug (regression yesterday). + * lib/csharpcomp.c (compile_csharp_using_sscli): Allocate the source + options with malloc() always, not sometimes with malloca() and sometimes + with malloc(). + 2024-10-07 Bruno Haible csharpcomp: Improve Cygwin support. diff --git a/lib/csharpcomp.c b/lib/csharpcomp.c index a0139c5b85..71e9633355 100644 --- a/lib/csharpcomp.c +++ b/lib/csharpcomp.c @@ -324,7 +324,7 @@ compile_csharp_using_sscli (const char * const *sources, we need to use cygpath_w. */ malloced = (char **) - xmalloca ((1 + libdirs_count + sources_count) * sizeof (char *)); + xmalloca ((1 + libdirs_count + sources_count * 2) * sizeof (char *)); mallocedp = malloced; argc = @@ -377,10 +377,10 @@ compile_csharp_using_sscli (const char * const *sources, 10) == 0) { char *option = - (char *) xmalloca (10 + strlen (source_file_converted) + 1); - + (char *) xmalloc (10 + strlen (source_file_converted) + 1); memcpy (option, "-resource:", 10); strcpy (option + 10, source_file_converted); + *mallocedp++ = option; *argp++ = option; } else @@ -404,9 +404,6 @@ compile_csharp_using_sscli (const char * const *sources, for (i = 2; i < 3 + libdirs_count + libraries_count; i++) freea ((char *) argv[i]); - for (i = 0; i < sources_count; i++) - if (argv[argc - sources_count + i] != sources[i]) - freea ((char *) argv[argc - sources_count + i]); while (mallocedp > malloced) free (*--mallocedp); freea (argv); -- 2.39.5