From: Oliver Kurth Date: Wed, 30 Oct 2019 18:18:23 +0000 (-0700) Subject: [open-vm-tools Coverity] Fix Coverity scan reported issues in copyPasteUIX11.cpp X-Git-Tag: stable-11.1.0~177 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72e9fb36520934a4f69b752f129d7068c77d0a02;p=thirdparty%2Fopen-vm-tools.git [open-vm-tools Coverity] Fix Coverity scan reported issues in copyPasteUIX11.cpp - Non-static class member mHGGetListTime is not initialized in this constructor solution: add it into init list of constructor - unsigned_compare: This greater-than-or-equal-to-zero comparison of an unsigned value is always true. end >= 0UL. Function: GetLastDirName --- diff --git a/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp b/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp index 89e5f661e..be8369e74 100644 --- a/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp +++ b/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp @@ -130,6 +130,7 @@ CopyPasteUIX11::CopyPasteUIX11() mPrimTime(0), mLastTimestamp(0), mThread(0), + mHGGetListTime(0), mHGGetFileStatus(DND_FILE_TRANSFER_NOT_STARTED), mBlockAdded(false), mBlockCtrl(0), @@ -1091,26 +1092,11 @@ CopyPasteUIX11::LocalGetSelectionFileList(const Gtk::SelectionData& sd) // utf::string CopyPasteUIX11::GetLastDirName(const utf::string &str) // IN { - utf::string ret; - size_t start; - size_t end; - - end = str.bytes() - 1; - if (end >= 0 && DIRSEPC == str[end]) { - end--; - } - - if (end <= 0 || str[0] != DIRSEPC) { - return ""; - } - - start = end; - - while (str[start] != DIRSEPC) { - start--; - } - - return str.substr(start + 1, end - start); + char *baseName; + File_GetPathName(str.c_str(), NULL, &baseName); + utf::string s(baseName); + free(baseName); + return s; }