diff --git a/LOG b/LOG index 6ee67a06d7..797320bc15 100644 --- a/LOG +++ b/LOG @@ -1419,10 +1419,20 @@ BUILDING, c/vs.bat, wininstall/locate-vcredist.bat - fixed open-string-input-port on immutable strings cpnanopass.ss, io.ms, release_notes.stex +- use setenv rather than putenv on non WIN32 environments + prim5.c, system.stex - restore {Free,Open,Net}BSD build, support Windows cross-compile via MinGW, add configuration options, and add helper makefile targets expenditor.c, thread.c, stats.c, statics.c, scheme.c, main.c, types.h, externs.h, globals.h, nocurses.h, version.h, system.h, segment.h, a6ob.def, ta6ob.def, a6nb.def, ta6nb.def, i3nt.def, ti3nt.def, c/Mf-*, build.bat, makefiles/Makefile.in, makefiles/Mf-install.in, - misc.ms, s/update-revision, BUILDING + s/update-revision, BUILDING +- export `ee-backward-delete-sexp` binding in the expression-editor module. + expeditor.ss +- fix ee_read_char to handle ^@ properly + expeditor.c +- prevent access before start of array + scheme.c +- remove dead stores in files + compress-io.c, new-io.c diff --git a/c/compress-io.c b/c/compress-io.c index 376cd03876..960dfb85b5 100644 --- a/c/compress-io.c +++ b/c/compress-io.c @@ -329,7 +329,7 @@ INT S_glzclose(glzFile glz) { #ifdef EINTR if (r < 0 && errno == EINTR) continue; #endif - if (r == 0) { r = Z_ERRNO; saved_errno = errno; } + if (r == 0) { saved_errno = errno; } break; } (void)LZ4F_freeDecompressionContext(lz4->dctx); diff --git a/c/expeditor.c b/c/expeditor.c index 5a6a50788c..c16865bc1e 100644 --- a/c/expeditor.c +++ b/c/expeditor.c @@ -691,11 +691,15 @@ static ptr s_ee_read_char(IBOOL blockp) { #endif /* PTHREADS */ if (n == 1) { - old_locale = uselocale(term_locale); - sz = mbrtowc(&wch, buf, 1, &term_out_mbs); - uselocale(old_locale); - if (sz == 1) { - return Schar(wch); + if (buf[0] == '\0') { + return Schar('\0'); + } else { + old_locale = uselocale(term_locale); + sz = mbrtowc(&wch, buf, 1, &term_out_mbs); + uselocale(old_locale); + if (sz == 1) { + return Schar(wch); + } } } diff --git a/c/new-io.c b/c/new-io.c index 2a896c19eb..74ed098b1f 100644 --- a/c/new-io.c +++ b/c/new-io.c @@ -842,8 +842,6 @@ ptr S_bytevector_compress(ptr dest_bv, iptr d_start, iptr d_count, if (!is_valid_lz4_length(s_count)) return Sstring("source bytevector ~s is too large"); - destLen = (int)d_count; - destLen = LZ4_compress_default((char *)&BVIT(src_bv, s_start), (char *)&BVIT(dest_bv, d_start), (int)s_count, (int)d_count); if (destLen > 0) diff --git a/c/prim5.c b/c/prim5.c index c8ba26424e..414a12dfed 100644 --- a/c/prim5.c +++ b/c/prim5.c @@ -1372,11 +1372,7 @@ static void s_putenv(name, value) char *name, *value; { if (rc == 0) S_error1("putenv", "environment extension failed: ~a", S_LastErrorString()); #else /* WIN32 */ - iptr n; char *s; - n = strlen(name) + strlen(value) + 2; - if ((s = malloc(n)) == (char *)NULL - || snprintf(s, n, "%s=%s", name, value) < 0 - || putenv(s) != 0) { + if (setenv(name, value, 1) != 0) { ptr msg = S_strerror(errno); if (msg != Sfalse) diff --git a/c/scheme.c b/c/scheme.c index 91eefaeeee..d94a989e3e 100644 --- a/c/scheme.c +++ b/c/scheme.c @@ -534,7 +534,7 @@ static IBOOL next_path(path, name, ext, sp, dsp) char *path; const char *name, * /* unless entry was null, append name and ext onto path and return true with * updated path, sp, and possibly dsp */ if (s != *sp) { - if (!DIRMARKERP(*(p - 1))) { setp(PATHSEP); } + if ((p > path) && !DIRMARKERP(*(p - 1))) { setp(PATHSEP); } t = name; while (*t != 0) setp(*t++); t = ext; diff --git a/csug/system.stex b/csug/system.stex index 005a456ccc..807b99b52d 100644 --- a/csug/system.stex +++ b/csug/system.stex @@ -5329,8 +5329,6 @@ is associated with \var{key}. environment of the process, where it is available to the current process (e.g., via \var{getenv}) and any spawned processes. -The key and value are copied into storage allocated outside of -the Scheme heap; this space is never reclaimed on non-Windows systems. \schemedisplay (putenv "SCHEME" "rocks!") diff --git a/release_notes/release_notes.stex b/release_notes/release_notes.stex index dd80ef4e71..bf0a485517 100644 --- a/release_notes/release_notes.stex +++ b/release_notes/release_notes.stex @@ -1749,6 +1749,12 @@ in fasl files does not generally make sense. %----------------------------------------------------------------------------- \section{Bug Fixes}\label{section:bugfixes} +\subsection{\protect\code{putenv} memory leak (9.5.3)} + +\scheme{putenv} now calls the host system's \scheme{setenv} instead of +\scheme{putenv} on non-Windows hosts and avoids allocating memory that +is never freed, although \scheme{setenv} might do so. + \subsection{String ports from immutable strings (9.5.4)} A bug that miscalculated the buffer size for diff --git a/s/expeditor.ss b/s/expeditor.ss index fadd08827d..04e554d4b6 100644 --- a/s/expeditor.ss +++ b/s/expeditor.ss @@ -82,8 +82,8 @@ ee-beginning-of-entry ee-end-of-entry ee-delete-to-eol ee-delete-line ee-delete-between-point-and-mark ee-set-mark - ee-delete-entry ee-reset-entry ee-delete-sexp ee-redisplay - ee-yank-kill-buffer ee-yank-selection + ee-delete-entry ee-reset-entry ee-delete-sexp ee-backward-delete-sexp + ee-redisplay ee-yank-kill-buffer ee-yank-selection ee-string-macro ee-eof ee-delete-char ee-eof/delete-char ee-backward-delete-char ee-insert-paren ee-flash-matching-delimiter ee-goto-matching-delimiter