From ce99a5e5d8ead9140bb9b48c01f1a200950f8ea3 Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Wed, 20 Apr 2016 09:09:30 +0200 Subject: [PATCH] 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. --- src/librustc_driver/target_features.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_driver/target_features.rs b/src/librustc_driver/target_features.rs index 69d146059c9c0..fad0af19a1270 100644 --- a/src/librustc_driver/target_features.rs +++ b/src/librustc_driver/target_features.rs @@ -54,6 +54,7 @@ pub fn add_configuration(cfg: &mut ast::CrateConfig, sess: &Session) { let tf = InternedString::new("target_feature"); for feat in whitelist { + assert_eq!(feat.chars().last(), Some('\0')); if unsafe { LLVMRustHasFeature(target_machine, feat.as_ptr() as *const c_char) } { cfg.push(attr::mk_name_value_item_str(tf.clone(), intern(&feat[..feat.len()-1]))) }