about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2016-04-20 09:09:30 +0200
committerAndrea Canciani <ranma42@gmail.com>2016-04-20 09:09:30 +0200
commitce99a5e5d8ead9140bb9b48c01f1a200950f8ea3 (patch)
treef904c2521dca6df81258dd99bbfebfba6f80037e /src
parentdeaa2fe7536e395a890f910019a820b36f2cd992 (diff)
downloadrust-ce99a5e5d8ead9140bb9b48c01f1a200950f8ea3.tar.gz
rust-ce99a5e5d8ead9140bb9b48c01f1a200950f8ea3.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_driver/target_features.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/librustc_driver/target_features.rs b/src/librustc_driver/target_features.rs
index 69d146059c9..fad0af19a12 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])))
         }