Ignore:
Timestamp:
Jan 18, 2012, 8:15:16 PM (14 years ago)
Author:
dmik
Message:

Remove usage of broken tempnam().

See #63 for details. This is a regression of r21928.
The fix actually simplifies the code as there was no
need in this function in the first place.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/oslibdnd.cpp

    r21928 r21944  
    2525#include "oslibdnd.h"
    2626
    27 static char *pszFile = NULL;
    2827static HWND  hwndTarget = 0;
    2928static PDRAGINFO curDragInfo = NULL;
    3029static char *pszCurDragData = NULL;
    3130
    32 #if 0
    33     FILE *tmpfile;
    34     tmpfile = fopen(pszFile, "wb+");   
    35     fwrite(lpszDnDString, 1, strlen(lpszDnDString)+1, tmpfile);
    36     fclose(tmpfile);
    37 #endif
    3831//******************************************************************************
    3932//******************************************************************************
     
    6255
    6356    char szDir[CCHMAXPATH*4];
    64    
    65     pszFile = tempnam(0, 0);
    66     if(pszFile == NULL) {
    67         DebugInt3();
    68         DrgFreeDraginfo(pdinfo);
    69         return NULL;
    70     }
    71 
    72     strcpy(szDir, pszFile);
    73 
    74     char *tmp = strrchr(szDir, '\\');
    75     if (!tmp)
    76         tmp = strrchr(szDir, '/');
    77     if (!tmp) {
    78         DebugInt3();
    79         free(pszFile);
    80         DrgFreeDraginfo(pdinfo);
    81         return NULL;
    82     }
    83 
    84     *tmp = 0;
    85     tmp++;
    86 
    87     dprintf(("temporary file %s", pszFile));
    88 
     57
     58    const char *pszTmpDir = getenv("TMP");
     59    if (!pszTmpDir)
     60        pszTmpDir = getenv("TEMP");
     61    if (!pszTmpDir)
     62        pszTmpDir = ".";
     63
     64    strncpy(szDir, pszTmpDir, sizeof(szDir) - 2);
     65    szDir[sizeof(szDir) - 2] = '\0'; // strncpy doesn't ensure this
    8966    strcat(szDir, "\\");
     67
     68    dprintf(("temporary dir %s", szDir));
    9069   
    9170    ditem.hwndItem       = pdinfo->hwndSource;
Note: See TracChangeset for help on using the changeset viewer.