diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-07-21 00:47:44 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-07-21 00:47:44 +0300 |
commit | fffbd86a1014ad169ed2d68ea58cdddf346faa14 (patch) | |
tree | 713c96fcf7421ca87f638d312e752179281cb8fe /src/utils | |
parent | 1941b81a5a278f26a5d7e1f91903ab04c92e2cd1 (diff) | |
download | plus-fffbd86a1014ad169ed2d68ea58cdddf346faa14.tar.gz plus-fffbd86a1014ad169ed2d68ea58cdddf346faa14.tar.bz2 plus-fffbd86a1014ad169ed2d68ea58cdddf346faa14.tar.xz plus-fffbd86a1014ad169ed2d68ea58cdddf346faa14.zip |
Add missing checks and non null attributes.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/chatutils.cpp | 4 | ||||
-rw-r--r-- | src/utils/copynpaste.cpp | 6 | ||||
-rw-r--r-- | src/utils/stringutils.h | 2 | ||||
-rw-r--r-- | src/utils/xml.cpp | 3 |
4 files changed, 8 insertions, 7 deletions
diff --git a/src/utils/chatutils.cpp b/src/utils/chatutils.cpp index c5b7e25ad..17ee9e11a 100644 --- a/src/utils/chatutils.cpp +++ b/src/utils/chatutils.cpp @@ -158,7 +158,9 @@ void replaceVars(std::string &str) StringVect names; std::string newStr; const Party *party = nullptr; - if (localPlayer->isInParty() && (party = localPlayer->getParty())) + if (localPlayer->isInParty() && + (party = localPlayer->getParty()) && + party) { party->getNames(names); FOR_EACH (StringVectCIter, it, names) diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index ce16bbab0..1f88d8abf 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -373,13 +373,9 @@ bool retrieveBuffer(std::string& text, size_t& pos) { Display *const dpy = info.info.x11.display; Window us = info.info.x11.window; - char *data = nullptr; requestAtom = XInternAtom(dpy, "UTF8_STRING", true); - - if (!data) - data = getSelection(dpy, us, XA_PRIMARY); - + char *data = getSelection(dpy, us, XA_PRIMARY); if (!data) data = getSelection(dpy, us, XA_SECONDARY); if (!data) diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 3307d6e73..67144ea65 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -99,7 +99,7 @@ const char *ipToString(const uint32_t address) A_WARN_UNUSED; /** * A safe version of sprintf that returns a std::string of the result. */ -std::string strprintf(const char *const format, ...) A_WARN_UNUSED +std::string strprintf(const char *const format, ...) A_NONNULL(1) A_WARN_UNUSED #ifdef __GNUC__ /* This attribute is nice: it even works through gettext invokation. For example, gcc will complain that strprintf(_("%s"), 42) is ill-formed. */ diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index 8642140c9..e9b2260bf 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -54,6 +54,9 @@ static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg, ...) if (msgSize * 3 > size) size = msgSize * 3; + if (!msg) + return; + char* buf = new char[size + 1]; va_list ap; |