From: Oliver Kurth Date: Wed, 11 Dec 2019 18:19:09 +0000 (-0800) Subject: [open-vm-tools Coverity] Fix Coverity scan reported issues in copyPasteUIX11.cpp X-Git-Tag: stable-11.0.5~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dab6d43fcb1b5a2f31b5e160c780a0dd4f1a03b7;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 fad000e3a..387cbc5ca 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), @@ -1090,26 +1091,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; }