Skip to content

Commit ce99a5e

Browse files
committed
Check that the feature strings are well-formed
Assert that the feature strings are NUL terminated, so that they will be well-formed as C strings. This is a safety check to ease the maintaninace and update of the feature lists.
1 parent deaa2fe commit ce99a5e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/librustc_driver/target_features.rs

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub fn add_configuration(cfg: &mut ast::CrateConfig, sess: &Session) {
5454

5555
let tf = InternedString::new("target_feature");
5656
for feat in whitelist {
57+
assert_eq!(feat.chars().last(), Some('\0'));
5758
if unsafe { LLVMRustHasFeature(target_machine, feat.as_ptr() as *const c_char) } {
5859
cfg.push(attr::mk_name_value_item_str(tf.clone(), intern(&feat[..feat.len()-1])))
5960
}

0 commit comments

Comments
 (0)