From: Bruno Haible Date: Wed, 9 Oct 2024 01:05:33 +0000 (+0200) Subject: csharpcomp: Fix memory management bug (regression yesterday). X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=5949b7855aff36e7e084d7f2c15b62575b258171;p=gnulib.git 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(). --- 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);