summaryrefslogtreecommitdiffstats
path: root/cli-downloader.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-26 19:00:48 +0100
committerGravatar Robert C. Helling <helling@atdotde.de>2021-01-26 20:20:09 +0100
commita6cfd181e89d67313532aeb8b5abbdc5540b43a6 (patch)
treeeb39543171f960ca4ea2e2baa13e7e572b007dc8 /cli-downloader.cpp
parentdc887f6d0a55cd32c309ab5402e1e135b492c7df (diff)
downloadsubsurface-a6cfd181e89d67313532aeb8b5abbdc5540b43a6.tar.gz
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>
Diffstat (limited to 'cli-downloader.cpp')
-rw-r--r--cli-downloader.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/cli-downloader.cpp b/cli-downloader.cpp
index a6a880e29..3eef0b2d5 100644
--- a/cli-downloader.cpp
+++ b/cli-downloader.cpp
@@ -14,11 +14,11 @@ void cliDownloader(const char *vendor, const char *product, const char *device)
data->setProduct(product);
data->setBluetoothMode(false);
if (data->vendor() == "Uemis") {
- char *colon;
- char *devname = strdup(device);
- if ((colon = strstr(devname, ":\\ (UEMISSDA)")) != NULL) {
- *(colon + 2) = '\0';
- fprintf(stderr, "shortened devname to \"%s\"", devname);
+ QString devname(device);
+ int colon = devname.indexOf(QStringLiteral(":\\ (UEMISSDA)"));
+ if (colon >= 0) {
+ devname.truncate(colon + 2);
+ fprintf(stderr, "shortened devname to \"%s\"", qPrintable(devname));
}
data->setDevName(devname);
} else {