fix `get-output-{bytes,string}' with bad starting index, no ending index

Closes PR 13933
This commit is contained in:
Matthew Flatt 2013-07-25 20:39:57 -06:00
parent 868e6b97b7
commit e0bab441a8
2 changed files with 12 additions and 2 deletions

View File

@ -211,6 +211,11 @@
(test #"23" get-output-bytes os #t 1 3)
(test #"" get-output-bytes os #f 0 #f))
(err/rt-test (get-output-bytes (open-output-bytes) #t 1))
(err/rt-test (get-output-bytes (open-output-bytes) #t 0 1))
(err/rt-test (get-output-bytes (open-output-string) #t 1))
(err/rt-test (get-output-bytes (open-output-string) #t 0 1))
(define s (open-output-string))
(err/rt-test (file-position 's 1))
(err/rt-test (file-position s 'one))

View File

@ -2648,7 +2648,7 @@ Scheme_Object *do_get_output_string(const char *who, int is_byte,
if (endpos < 0)
endpos = len+1;
}
if (!(startpos <= len)) {
scheme_out_of_range(who, "port", "starting ", argv[2], argv[0], 0, len);
return NULL;
@ -2657,8 +2657,13 @@ Scheme_Object *do_get_output_string(const char *who, int is_byte,
scheme_out_of_range(who, "port", "ending ", argv[3], argv[0], startpos, len);
return NULL;
}
} else
} else {
if (!(startpos <= len)) {
scheme_out_of_range(who, "port", "starting ", argv[2], argv[0], 0, len);
return NULL;
}
endpos = -1;
}
} else {
startpos = 0;
endpos = -1;