| 1 |
diff --git a/image/encode/strenc.c b/image/encode/strenc.c |
| 2 |
index d6e970e..1a7e0b2 100644 |
| 3 |
--- a/image/encode/strenc.c |
| 4 |
+++ b/image/encode/strenc.c |
| 5 |
@@ -482,11 +482,22 @@ Int StrIOEncInit(CWMImageStrCodec* pSC) |
| 6 |
pSC->ppTempFile[i] = (char *)malloc(FILENAME_MAX * sizeof(char)); |
| 7 |
if(pSC->ppTempFile[i] == NULL) return ICERR_ERROR; |
| 8 |
|
| 9 |
- if ((pFilename = tmpnam(NULL)) == NULL) |
| 10 |
+ char tmpnambuf[] = {'f', 'i', 'l', 'e', 'X', 'X', 'X', 'X', 'X', 'X', '\0'}; |
| 11 |
+ int fileDescriptor = mkstemp(tmpnambuf); |
| 12 |
+ if (fileDescriptor == -1) |
| 13 |
return ICERR_ERROR; |
| 14 |
+ close(fileDescriptor); |
| 15 |
strcpy(pSC->ppTempFile[i], pFilename); |
| 16 |
#endif |
| 17 |
- if(CreateWS_File(pSC->ppWStream + i, pFilename, "w+b") != ICERR_OK) return ICERR_ERROR; |
| 18 |
+ if(CreateWS_File(pSC->ppWStream + i, pFilename, "w+b") != ICERR_OK) |
| 19 |
+ { |
| 20 |
+ #ifdef _WINDOWS_ |
| 21 |
+ DeleteFileA(pFilename); |
| 22 |
+ #else |
| 23 |
+ remove(pFilename); |
| 24 |
+ #endif |
| 25 |
+ return ICERR_ERROR; |
| 26 |
+ } |
| 27 |
|
| 28 |
} |
| 29 |
else { |