Thread (1 message) 1 message, 1 author, 2019-02-15

Re: [PATCH 1/1] mingw: safe-guard a bit more against getenv() problems

From: Junio C Hamano <hidden>
Date: 2019-02-15 18:25:30

Jeff Hostetler [off-list ref] writes:
quoted
diff --git a/compat/mingw.c b/compat/mingw.c
index 4276297595..8141f77189 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1632,7 +1632,7 @@ int mingw_kill(pid_t pid, int sig)
   */
  char *mingw_getenv(const char *name)
  {
-#define GETENV_MAX_RETAIN 30
+#define GETENV_MAX_RETAIN 64
  	static char *values[GETENV_MAX_RETAIN];
  	static int value_counter;
  	int len_key, len_value;
Why not use a mem_pool for this?  We have that code isolated
and re-usable now.  Have mingw_getenv() copy the string into
the pool always return the pointer from within the pool.  The
pool automatically handles allocating new blocks as necessary.
And (if we care) we can bulk free the pool before existing.
Probably a good idea in the longer term.  The patch as posted would
do for the upcoming release, though.

Thanks, both.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help