]> xenbits.xensource.com Git - freebsd.git/commitdiff
loader_4th: scan_buffer can leave empty string on stack
authortsoome <tsoome@FreeBSD.org>
Mon, 16 Sep 2019 20:26:53 +0000 (20:26 +0000)
committertsoome <tsoome@FreeBSD.org>
Mon, 16 Sep 2019 20:26:53 +0000 (20:26 +0000)
When the file processing is done, we will have string with lenght 0 in stack and we will attempt to
allocate 0 bytes.

stand/forth/support.4th

index aa50b3bb3a9d3534661bdcb7ab2ccb949d5621df..64c71e12ec2656e2d419f9e581651c5e8c3ceb44 100644 (file)
@@ -363,6 +363,7 @@ variable fd
 ;
 
 : line_buffer_resize  ( len -- len )
+  dup 0= if exit then
   >r
   line_buffer .len @ if
     line_buffer .addr @
@@ -376,6 +377,7 @@ variable fd
 ;
     
 : append_to_line_buffer  ( addr len -- )
+  dup 0= if 2drop exit then
   line_buffer strget
   2swap strcat
   line_buffer .len !