Fixed small memory leak in libprofile (#141739)
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.
GitOrigin-RevId: 2b1ebef8b8a5af7092de80daafd2743683d0e8c8
diff --git a/lib/profile/InstrProfilingFile.c b/lib/profile/InstrProfilingFile.c
index e6bab95..354f21b 100644
--- a/lib/profile/InstrProfilingFile.c
+++ b/lib/profile/InstrProfilingFile.c
@@ -1088,8 +1088,10 @@
return "\0";
}
Filename = getCurFilename(FilenameBuf, 1);
- if (!Filename)
+ if (!Filename) {
+ free(FilenameBuf);
return "\0";
+ }
return FilenameBuf;
}