mkstemp in Player::AddTheme

Tim Lesher <[email protected]>
Newsgroups gmane.comp.audio.zinf.devel
Message-ID <[email protected]>
It looks like mkstemp() is being misused in Player::AddTheme:

Player::AddTheme looks like this:

---
void Player::AddTheme(const char *url)
{
    string     szSavedTheme, szNewTheme;
    char       *pTempFile = new char[13];
    
    m_context->prefs->GetPrefString(kThemePref, szSavedTheme);
    URLToFilePath(url, szNewTheme); 
    strncpy(pTempFile,"themeXXXXXX",13);
    mkstemp (pTempFile);
    if (CopyFile(szNewTheme.c_str(), pTempFile, false))
        AcceptEvent(new LoadThemeEvent(pTempFile, 
        szSavedTheme.c_str()));
    delete [] pTempFile;
}
---

mkstemp() actually opens the file with O_EXCL, returning an fd.  Am I
missing something obvious, or will this leak the fd?  

The only reason I know for using mkstemp() over mktemp() is when you
want to actually use the fd in writing to avoid the well-known
mktemp() race condition.  If we're not doing that, any reason this
shouldn't just call mktemp(), which is POSIX-standard?

-- 
Tim Lesher <[email protected]>
http://www.lesher.ws



-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.