-
Notifications
You must be signed in to change notification settings - Fork 1
cov-test: Fixing High and medium level issues[DONOT MERGE] #107
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -330,7 +330,6 @@ void NativeJSRenderer::createApplicationInternal(ApplicationRequest& appRequest) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context->setCreateApplicationEndTime(endTime, id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mContextMap[id].context=context; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mUserMutex.unlock(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void NativeJSRenderer::runApplicationInternal(ApplicationRequest& appRequest) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -445,7 +444,7 @@ void NativeJSRenderer::terminateApplicationInternal(ApplicationRequest& AppReque | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NativeJSLogger::log(ERROR, "Unable to find application with id: %d and url: %s\n", id, mContextMap[id].url); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NativeJSLogger::log(ERROR, "Unable to find application with id: %d and url: %s\n", id, mContextMap[id].url.c_str()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NativeJSLogger::log(ERROR, "Unable to find application with id: %d and url: %s\n", id, mContextMap[id].url.c_str()); | |
| NativeJSLogger::log(ERROR, "Unable to find application with id: %d\n", id); |
Copilot
AI
Jan 16, 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 variable id is declared inside the if block on line 507 but is used to initialize ApplicationRequest on line 509. Since uint32_t is uninitialized, this will result in using an indeterminate value. Initialize id before using it or ensure it's assigned a valid value.
| uint32_t id; | |
| uint32_t id = 0; |
Copilot
AI
Jan 16, 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.
After checking if curl_easy_setopt fails and logging an error, the code calls curl_easy_cleanup but continues execution instead of returning immediately. This results in attempting to use an already-cleaned-up curl handle in subsequent curl_easy_setopt calls, which leads to undefined behavior. Add a return statement after curl_easy_cleanup to exit the function early on error.
| curl_easy_cleanup(curl); | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_SSL_VERIFYHOST: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_SSL_VERIFYPEER: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0"); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_USERAGENT: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_PROXY, ""); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_PROXY: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| curl_easy_cleanup(curl); | |
| return ret; | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_SSL_VERIFYHOST: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| return ret; | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_SSL_VERIFYPEER: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| return ret; | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0"); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_USERAGENT: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| return ret; | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_PROXY, ""); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_PROXY: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| return ret; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,7 +115,7 @@ void dispatchPending() | |
| { | ||
| std::unique_lock<std::mutex> lock(gDispatchMutex); | ||
| std::list<std::function<void ()>> pending = std::move(gPendingFun); | ||
| gDispatchMutex.unlock(); | ||
| lock.unlock(); | ||
| for(auto& fun : pending) | ||
| fun(); | ||
| } | ||
|
|
@@ -321,17 +321,32 @@ rtError rtReadBinaryBinding(int numArgs, const rtValue* args, rtValue* result, v | |
| const char *fd = "hello.wasm"; | ||
| struct stat buf; | ||
|
|
||
| stat(fd, &buf); | ||
| if (stat(fd, &buf) != 0) | ||
| { | ||
| rtLogError("Failed to stat file: %s", fd); | ||
| fclose(ptr); | ||
| return RT_ERROR; | ||
| } | ||
|
|
||
| int size = buf.st_size; | ||
|
|
||
| buffer = (char*)malloc(size); | ||
| fread(buffer,size,1,ptr); // read 10 bytes to our buffer | ||
| size_t bytesRead = fread(buffer, size, 1, ptr); | ||
| fclose(ptr); | ||
|
Comment on lines
+324
to
335
|
||
|
|
||
| if (bytesRead != 1) | ||
| { | ||
| rtLogError("Failed to read file: expected 1 item, read %zu items", bytesRead); | ||
| free(buffer); | ||
| return RT_ERROR; | ||
| } | ||
|
|
||
| if (result) | ||
| { | ||
| result->setString(buffer); | ||
| } | ||
|
|
||
| free(buffer); | ||
| return RT_OK; | ||
| } | ||
|
|
||
|
|
@@ -693,13 +708,15 @@ rtError rtJSRuntimeDownloadMetrics(int numArgs, const rtValue* args, rtValue* re | |
| rtValue keys; | ||
| if (map->Get("allKeys", &keys) != RT_OK) { | ||
| rtLogWarn("Could not retrieve url for network metrics data."); | ||
| delete netMetricsArray; //newly added | ||
| return RT_FAIL; | ||
| } | ||
| rtObjectRef objRef = keys.toObject(); | ||
| rtArrayObject* keysArray = static_cast<rtArrayObject*>(objRef.getPtr()); | ||
|
|
||
| if (!keysArray) { | ||
| rtLogWarn("No url found in the network metrics data."); | ||
| delete netMetricsArray; //newly added | ||
| return RT_FAIL; | ||
| } | ||
|
|
||
|
|
@@ -715,6 +732,7 @@ rtError rtJSRuntimeDownloadMetrics(int numArgs, const rtValue* args, rtValue* re | |
| NetworkMetrics* metrics = (NetworkMetrics*)storedValue.toVoidPtr(); | ||
| if (!metrics) { | ||
| rtLogError("Failed to cast stored value to NetworkMetrics structure for url: %s.", key.cString()); | ||
| delete netMetricsArray; //newly added | ||
| return RT_FAIL; | ||
| } | ||
| rtMapObject* metricsMap = new rtMapObject(); | ||
|
|
||
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.
Missing space in error message. The error message concatenates name directly with "is" without a space separator, resulting in output like "valueis not a Uint32_t" instead of "value is not a Uint32_t".