0

Avoid setting empty options in PrinterBasicInfo

The basic information read back from Print Spooler API calls can
include valid pointers to empty strings for data that is stored as
options.  These blank options have no value, so there is no need to set
them in such cases.

Change-Id: Iab8f5b00c4c1175848fa46cc48a9b3911990ffe1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6271515
Commit-Queue: Alan Screen <awscreen@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1420826}
This commit is contained in:
Alan Screen
2025-02-14 17:39:25 -08:00
committed by Chromium LUCI CQ
parent be064f96ec
commit e587726abe

@ -413,12 +413,16 @@ std::optional<PrinterBasicInfo> GetBasicPrinterInfo(HANDLE printer) {
printer_info.printer_description = base::WideToUTF8(info_2.get()->pComment);
}
if (info_2.get()->pLocation) {
printer_info.options[kLocationTagName] =
base::WideToUTF8(info_2.get()->pLocation);
std::string location = base::WideToUTF8(info_2.get()->pLocation);
if (!location.empty()) {
printer_info.options[kLocationTagName] = std::move(location);
}
}
if (info_2.get()->pDriverName) {
printer_info.options[kDriverNameTagName] =
base::WideToUTF8(info_2.get()->pDriverName);
std::string driver_name = base::WideToUTF8(info_2.get()->pDriverName);
if (!driver_name.empty()) {
printer_info.options[kDriverNameTagName] = std::move(driver_name);
}
}
return printer_info;
}