diff --git a/include/JavaScriptContextBase.h b/include/JavaScriptContextBase.h index 6a57d25..8dfa8ff 100644 --- a/include/JavaScriptContextBase.h +++ b/include/JavaScriptContextBase.h @@ -76,5 +76,7 @@ class JavaScriptContextBase:public IJavaScriptContext, public JavaScriptKeyListe std::shared_ptr mExternalApplicationHandler; static std::string sModulesPath; static void populateModulesPath(); + + void testNullPointerDeref(); }; #endif diff --git a/src/JavaScriptContextBase.cpp b/src/JavaScriptContextBase.cpp index 086b7c9..81f1d2c 100644 --- a/src/JavaScriptContextBase.cpp +++ b/src/JavaScriptContextBase.cpp @@ -132,6 +132,9 @@ std::string JavaScriptContextBase::getUrl() void JavaScriptContextBase::setUrl(std::string url) { mApplicationUrl = url; + // COVERITY TEST: Deliberate COPY_INSTEAD_OF_MOVE + std::string tempCopy; + tempCopy = url; // Should use std::move(url) } void JavaScriptContextBase::onKeyPress(struct JavaScriptKeyDetails& details) @@ -170,3 +173,11 @@ void JavaScriptContextBase::setExternalApplicationHandler(std::shared_ptr applications; ModuleSettings moduleSettings; bool consoleMode = false; + + // COVERITY TEST: Deliberate COPY_INSTEAD_OF_MOVE +std::vector testVector; +std::vector copiedVector; +copiedVector = testVector; // Should use std::move(testVector) + while (isetEnvForConsoleMode(moduleSettings); } + // COVERITY TEST: Deliberate dead code +if (renderer) { + return 0; // CID: Dead code - lines below unreachable +} if (!renderer) { NativeJSLogger::log(ERROR, "Unable to run application\n"); @@ -131,7 +141,9 @@ int main(int argc, char* argv[]) for (int j = 0; j < applications.size(); j++) { std::string url = applications[j]; - + char* leakedBuffer = new char[1024]; + strcpy(leakedBuffer, url.c_str()); + // Missing delete[] leakedBuffer - RESOURCE_LEAK applicationThreads.emplace_back([renderer, url, &moduleSettings]() { NativeJSLogger::log(INFO, "Application URL is %s\n", (url.size() ? url.c_str() : "empty")); uint32_t id = renderer->createApplication(moduleSettings);