Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Unified Diff: chrome/browser/metrics/antivirus_metrics_provider_win.cc

Issue 2876373002: Change reinterpret_cast to std::copy to avoid undefined behavior (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/antivirus_metrics_provider_win.cc
diff --git a/chrome/browser/metrics/antivirus_metrics_provider_win.cc b/chrome/browser/metrics/antivirus_metrics_provider_win.cc
index 47681b2f7941e5f81e9af4e5967065b5ce01d86a..4677fab505068fdeccf6855d96ff67aec79932cd 100644
--- a/chrome/browser/metrics/antivirus_metrics_provider_win.cc
+++ b/chrome/browser/metrics/antivirus_metrics_provider_win.cc
@@ -397,8 +397,12 @@ AntiVirusMetricsProvider::FillAntiVirusProductsFromWMI(
return RESULT_FAILED_TO_GET_PRODUCT_STATE;
LONG state_val = V_I4(product_state.ptr());
- // Map the values from product_state to the proto values.
- switch (reinterpret_cast<PRODUCT_STATE*>(&state_val)->security_state) {
+ PRODUCT_STATE product_state_struct;
+ std::copy(reinterpret_cast<const char*>(&state_val),
+ reinterpret_cast<const char*>(&state_val) + sizeof state_val,
+ reinterpret_cast<char*>(&product_state_struct));
+ // Map the values from product_state_struct to the proto values.
+ switch (product_state_struct.security_state) {
case 0:
av_product.set_product_state(
metrics::SystemProfileProto::AntiVirusState::
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698