Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix undefined behavior in `energymon::init` #26641

Merged
merged 1 commit into from May 26, 2020
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -29,7 +29,6 @@ mod energymon {

use self::energy_monitor::EnergyMonitor;
use self::energymon::EnergyMon;
use std::mem;
use std::sync::{Once, ONCE_INIT};

static mut EM: Option<*mut EnergyMon> = None;
@@ -41,7 +40,7 @@ mod energymon {
if let Ok(em) = EnergyMon::new() {
println!("Started energy monitoring from: {}", em.source());
unsafe {
EM = Some(mem::transmute(Box::new(em)));
EM = Some(Box::into_raw(Box::new(em)));
}
}
});
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.