downloader: don't leak device name

For Uemis there was string-manipulation that leaked the
temporary string. Use QString instead in order not to have
to bother about such things.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-01-26 19:00:48 +01:00 committed by Robert C. Helling
parent dc887f6d0a
commit a6cfd181e8

View file

@ -14,11 +14,11 @@ void cliDownloader(const char *vendor, const char *product, const char *device)
data->setProduct(product); data->setProduct(product);
data->setBluetoothMode(false); data->setBluetoothMode(false);
if (data->vendor() == "Uemis") { if (data->vendor() == "Uemis") {
char *colon; QString devname(device);
char *devname = strdup(device); int colon = devname.indexOf(QStringLiteral(":\\ (UEMISSDA)"));
if ((colon = strstr(devname, ":\\ (UEMISSDA)")) != NULL) { if (colon >= 0) {
*(colon + 2) = '\0'; devname.truncate(colon + 2);
fprintf(stderr, "shortened devname to \"%s\"", devname); fprintf(stderr, "shortened devname to \"%s\"", qPrintable(devname));
} }
data->setDevName(devname); data->setDevName(devname);
} else { } else {