From 04593e8ec4bac2606dec54605c72a6a49cc83f9b Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 24 Mar 2019 21:50:01 +0100 Subject: Cleanup: fix printGPSCoords signature and leaks The printGPSCoords() function returns a copied C-style string. Since the owndership is transferred to the caller, the correct return type is "char *" instead of "const char *". Thus a number of casts when calling free can be removed. Moreover a number of callers didn't free the string and thus were leaking memory. Fix them. Ultimately we might want two versions of the function: one for QString, one for C-style strings. Signed-off-by: Berthold Stoeger --- desktop-widgets/tab-widgets/maintab.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'desktop-widgets/tab-widgets') diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 11ad99d50..a2ff15368 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -411,9 +411,9 @@ void MainTab::updateDiveInfo(bool clear) ui.locationTags->setText(constructLocationTags(&ds->taxonomy, true)); if (ui.locationTags->text().isEmpty() && has_location(&ds->location)) { - const char *coords = printGPSCoords(&ds->location); + char *coords = printGPSCoords(&ds->location); ui.locationTags->setText(coords); - free((void *)coords); + free(coords); } } else { ui.location->clear(); -- cgit v1.2.3-70-g09d2