{string,bytes}->path-element: error on empty [byte] string

This commit is contained in:
Matthew Flatt 2013-11-03 09:57:26 -07:00
parent dee76b58a9
commit afcecc73f1
3 changed files with 17 additions and 7 deletions

View File

@ -897,6 +897,9 @@
(err/rt-test (bytes->path-element "a/b" 'unix))
(err/rt-test (bytes->path-element "a\\b" 'windows))
(err/rt-test (bytes->path-element #""))
(err/rt-test (string->path-element ""))
(test #"\\\\?\\REL\\\\a/b" path->bytes (bytes->path-element #"a/b" 'windows))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -1,5 +1,7 @@
Version 5.90.0.10
Added chaperone-channel and impersonate-channel
Change string->path-element and bytes->path-element to raise an
exception for an empty [byte-]string argument
Version 5.90.0.9
Allow hash table chaperones and impersonators to support efficient

View File

@ -1036,19 +1036,24 @@ static Scheme_Object *do_bytes_to_path_element(const char *name, Scheme_Object *
}
}
if (i >= len)
p = make_protected_sized_offset_path(1, SCHEME_BYTE_STR_VAL(s),
0, len,
SCHEME_MUTABLEP(s), 0,
kind);
else
if (i >= len) {
if (len == 0)
p = NULL;
else
p = make_protected_sized_offset_path(1, SCHEME_BYTE_STR_VAL(s),
0, len,
SCHEME_MUTABLEP(s), 0,
kind);
} else
p = NULL;
if (!p || !is_path_element(p))
scheme_contract_error(name,
"cannot be converted to a path element",
"path", 1, argv[0],
"explanation", 0, "path can be split, is not relative, or names a special element",
"explanation", 0, (len
? "path can be split, is not relative, or names a special element"
: "path element cannot be empty"),
NULL);
return p;