Skip to content

Commit e98a363

Browse files
committed
Use unique file names for temporary files used for analysis
1 parent 893e4ee commit e98a363

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Deployment.
6060
- Parse `--xml` output instead of text output. (Contribution by @firewave)
6161
- Fixed scanning of files with whitespaces in name. (Contribution by @firewave)
6262
- Only scan files which actually exist. (Contribution by @firewave)
63+
- Use unique file names for temporary files used for analysis. (Contribution by @firewave)
6364

6465
### 1.5.1 - 2020-11-12
6566

resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
- Parse --xml output instead of text output. (Contribution by @firewave)<br/>
6565
- Fixed scanning of files with whitespaces in name. (Contribution by @firewave)
6666
- Only scan files which actually exist. (Contribution by @firewave)
67+
- Use unique file names for temporary files used for analysis. (Contribution by @firewave)
6768
]]>
6869
</change-notes>
6970

src/com/github/johnthagen/cppcheck/CppcheckInspection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.intellij.openapi.vfs.VirtualFile;
1414
import com.intellij.openapi.wm.StatusBar;
1515
import com.intellij.psi.PsiFile;
16+
import org.apache.commons.lang3.RandomStringUtils;
1617
import org.jetbrains.annotations.NotNull;
1718
import org.jetbrains.annotations.Nullable;
1819
import org.xml.sax.SAXException;
@@ -55,7 +56,7 @@ public ProblemDescriptor[] checkFile(@NotNull PsiFile file,
5556

5657
File tempFile = null;
5758
try {
58-
tempFile = FileUtil.createTempFile("", vFile.getName(), true);
59+
tempFile = FileUtil.createTempFile(RandomStringUtils.randomAlphanumeric(8) + "_", vFile.getName(), true);
5960
FileUtil.writeToFile(tempFile, document.getText());
6061
final String cppcheckOutput =
6162
CppCheckInspectionImpl.executeCommandOnFile(cppcheckPath, prependIncludeDir(cppcheckOptions, vFile),

0 commit comments

Comments
 (0)