-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Fixed small memory leak in libprofile #141739
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
Conversation
@llvm/pr-subscribers-pgo Author: None (gbMattN) ChangesInside
If this is true, we return Full diff: https://github.com/llvm/llvm-project/pull/141739.diff 1 Files Affected:
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c b/compiler-rt/lib/profile/InstrProfilingFile.c
index e6bab9533146b..354f21b786151 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -1088,8 +1088,10 @@ const char *__llvm_profile_get_filename(void) {
return "\0";
}
Filename = getCurFilename(FilenameBuf, 1);
- if (!Filename)
+ if (!Filename) {
+ free(FilenameBuf);
return "\0";
+ }
return FilenameBuf;
}
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/16089 Here is the relevant piece of the build log for the reference
|
From the buildbot it looks like my commit may be the one that broke this, but the break is in the file
I think this commit is fine then, since it doesn't touch that file, nor mess with any type definitions |
Inside `getCurFilename`, there is this code snippit ``` if (!lprofCurFilename.FilenamePat || !lprofCurFilename.FilenamePat[0]) return 0; ``` If this is true, we return `"\0"`, but would leak the memory in `FilenameBuf`. This pull request adds a free before then to properly free the memory. There was already a check that we allocated memory, so there is no need to worry about freeing unallocated memory.
Inside
getCurFilename
, there is this code snippitIf this is true, we return
"\0"
, but would leak the memory inFilenameBuf
.This pull request adds a free before then to properly free the memory. There was already a check that we allocated memory, so there is no need to worry about freeing unallocated memory.