From f3b13fe80846d0ad039c7517c5e1174fca340917 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Tue, 9 Mar 2004 03:46:42 +0000 Subject: [PATCH] Don't try to allocate zero-length string in RELOAD-SAVE-STRING. --- v7/src/microcode/boot.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/v7/src/microcode/boot.c b/v7/src/microcode/boot.c index 491e37118..83c2d7152 100644 --- a/v7/src/microcode/boot.c +++ b/v7/src/microcode/boot.c @@ -1,10 +1,10 @@ /* -*-C-*- -$Id: boot.c,v 9.116 2003/07/22 02:19:51 cph Exp $ +$Id: boot.c,v 9.117 2004/03/09 03:46:42 cph Exp $ Copyright 1986,1987,1988,1989,1990,1991 Massachusetts Institute of Technology Copyright 1992,1993,1994,1995,1996,1997 Massachusetts Institute of Technology -Copyright 2000,2001,2002,2003 Massachusetts Institute of Technology +Copyright 2000,2001,2002,2003,2004 Massachusetts Institute of Technology This file is part of MIT/GNU Scheme. @@ -708,17 +708,18 @@ DEFINE_PRIMITIVE ("RELOAD-SAVE-STRING", Prim_reload_save_string, 1, 1, 0) CHECK_ARG (1, STRING_P); { unsigned int length = (STRING_LENGTH (ARG_REF (1))); - reload_saved_string = (malloc (length)); - if (reload_saved_string == 0) - error_external_return (); - reload_saved_string_length = length; - { - char * scan = ((char *) (STRING_LOC ((ARG_REF (1)), 0))); - char * end = (scan + length); - char * scan_result = reload_saved_string; - while (scan < end) - (*scan_result++) = (*scan++); - } + if (length > 0) + { + reload_saved_string = (OS_malloc (length)); + reload_saved_string_length = length; + { + char * scan = ((char *) (STRING_LOC ((ARG_REF (1)), 0))); + char * end = (scan + length); + char * scan_result = reload_saved_string; + while (scan < end) + (*scan_result++) = (*scan++); + } + } } } PRIMITIVE_RETURN (UNSPECIFIC); -- 2.25.1