-
Notifications
You must be signed in to change notification settings - Fork 1
Checking the coverity issue[Do Not Merge] #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -225,10 +225,8 @@ void NativeJSRenderer::setEnvForConsoleMode(ModuleSettings& moduleSettings) | |||||||||||||||||||
|
|
||||||||||||||||||||
| uint32_t NativeJSRenderer::createApplicationIdentifier() | ||||||||||||||||||||
| { | ||||||||||||||||||||
| static uint32_t id = 1; | ||||||||||||||||||||
| uint32_t ret = id; | ||||||||||||||||||||
| id++; | ||||||||||||||||||||
| return ret; | ||||||||||||||||||||
| static std::atomic<uint32_t> id{1}; | ||||||||||||||||||||
| return id++; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| uint32_t NativeJSRenderer::createApplication(ModuleSettings& moduleSettings, std::string userAgent) | ||||||||||||||||||||
|
|
@@ -292,6 +290,7 @@ bool NativeJSRenderer::terminateApplication(uint32_t id) | |||||||||||||||||||
| return true; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // REQUIRES: Caller must hold mUserMutex | ||||||||||||||||||||
| void NativeJSRenderer::createApplicationInternal(ApplicationRequest& appRequest) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| double startTime = getTimeInMilliSec(); | ||||||||||||||||||||
|
|
@@ -330,9 +329,9 @@ void NativeJSRenderer::createApplicationInternal(ApplicationRequest& appRequest) | |||||||||||||||||||
| context->setCreateApplicationEndTime(endTime, id); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| mContextMap[id].context=context; | ||||||||||||||||||||
| mUserMutex.unlock(); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // REQUIRES: Caller must hold mUserMutex | ||||||||||||||||||||
| void NativeJSRenderer::runApplicationInternal(ApplicationRequest& appRequest) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| uint32_t id = appRequest.mId; | ||||||||||||||||||||
|
|
@@ -365,7 +364,7 @@ void NativeJSRenderer::runApplicationInternal(ApplicationRequest& appRequest) | |||||||||||||||||||
| NativeJSLogger::log(INFO, "Adding the window location: %s to js file\n", window.str().c_str()); | ||||||||||||||||||||
| context->runScript(window.str().c_str(),true, url, nullptr, true); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| NativeJSLogger::log(INFO, "nativeJS application thunder execution url: %s, result: %d\n", url.c_str(), ret ? 1 : 0); | ||||||||||||||||||||
| NativeJSLogger::log(INFO, "nativeJS application thunder execution url: %s\n", url.c_str()); | ||||||||||||||||||||
|
||||||||||||||||||||
| NativeJSLogger::log(INFO, "nativeJS application thunder execution url: %s\n", url.c_str()); |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ApplicationRequest created here uses the RUN type but calls both createApplicationInternal and runApplicationInternal. This is inconsistent with the normal flow where a CREATE type request would be used for createApplicationInternal. This means the appRequest has type RUN when it's passed to createApplicationInternal, which might cause issues if createApplicationInternal logic depends on the request type.
| ApplicationRequest appRequest(id, RUN, mTestFileName, settings.enableHttp, settings.enableXHR, settings.enableWebSocket, settings.enableWebSocketEnhanced, settings.enableFetch, settings.enableJSDOM, settings.enableWindow, settings.enablePlayer); | |
| mUserMutex.lock(); | |
| NativeJSRenderer::createApplicationInternal(appRequest); | |
| NativeJSRenderer::runApplicationInternal(appRequest); | |
| ApplicationRequest createRequest(id, CREATE, mTestFileName, settings.enableHttp, settings.enableXHR, settings.enableWebSocket, settings.enableWebSocketEnhanced, settings.enableFetch, settings.enableJSDOM, settings.enableWindow, settings.enablePlayer); | |
| ApplicationRequest runRequest(id, RUN, mTestFileName, settings.enableHttp, settings.enableXHR, settings.enableWebSocket, settings.enableWebSocketEnhanced, settings.enableFetch, settings.enableJSDOM, settings.enableWindow, settings.enablePlayer); | |
| mUserMutex.lock(); | |
| NativeJSRenderer::createApplicationInternal(createRequest); | |
| NativeJSRenderer::runApplicationInternal(runRequest); |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same curl handle cleanup issue exists here as in jsc_lib.cpp. The lambda captures curl by reference and calls curl_easy_cleanup, but doesn't set the pointer to nullptr. While this doesn't cause a double-free due to immediate return, consider setting curl to nullptr after cleanup for defensive programming consistency.
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lambda captures curl by reference and then sets it to nullptr inside the lambda when an error occurs. This creates a problem because after setting curl to nullptr, subsequent calls to setOptWithCheck will still use the captured reference which is now nullptr, leading to a crash. After the first failure, curl_easy_cleanup is called with a valid handle and curl is set to nullptr, but the reference 'curl' in the outer scope becomes nullptr. This means if curl_easy_perform is reached later (though it won't be due to early returns), it would try to use a null pointer.
Consider either: 1) Not setting curl to nullptr in the lambda, or 2) Check if curl is nullptr before each subsequent call.
Uh oh!
There was an error while loading. Please reload this page.