Official eMule-Board: Missing Unlock In Ised2klinkinclipboard - Official eMule-Board

Jump to content


Page 1 of 1

Missing Unlock In Ised2klinkinclipboard

#1 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 05 October 2005 - 09:44 AM

Quote

bool CemuleApp::IsEd2kLinkInClipboard(LPCSTR pszLinkType, int iLinkTypeLen)
{
bool bFoundLink = false;
if (IsClipboardFormatAvailable(CF_TEXT))
{
  if (OpenClipboard(NULL))
  {
  HGLOBAL hText = GetClipboardData(CF_TEXT);
  if (hText != NULL)
  {
    // Use the ANSI string
    LPCSTR pszText = (LPCSTR)GlobalLock(hText);
    if (pszText != NULL)
    {
    while (*pszText == ' ' || *pszText == '\t' || *pszText == '\r' || *pszText == '\n')
      pszText++;
    bFoundLink = (strncmp(pszText, pszLinkType, iLinkTypeLen) == 0);
    //GlobalUnlock(hText);
    }
    GlobalUnlock(hText); //WiZaRd
  }
...

It should never happen, though, it's better to unlock correctly :lol:
0

#2 User is offline   SlugFiller 

  • The one and only master slug
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 6988
  • Joined: 15-September 02

Posted 05 October 2005 - 10:16 AM

I don't think you understand what "GlobalLock" does.
It's less like "CSingleLock::Lock", and more like "malloc".
"GlobalUnlock" is therefore like "free".

So this code is sort of like:
    LPCSTR pszText = (LPCSTR)malloc(...);
    if (pszText != NULL)
    {
    ...
    free(pszText);
    }

Your "fix" is hence:
    LPCSTR pszText = (LPCSTR)malloc(...);
    if (pszText != NULL)
    {
    ...
    //free(pszText);
    }
    free(pszText);

I hope the issue is visible.
Why haven't you clicked yet?

SlugFiller rule #1: Unsolicited PMs is the second most efficient method to piss me off.
SlugFiller rule #2: The first most efficient method is unsolicited eMails.
SlugFiller rule #3: If it started in a thread, it should end in the same thread.
SlugFiller rule #4: There is absolutely no reason to perform the same discussion twice in parallel, especially if one side is done via PM.
SlugFiller rule #5: Does it say "Group: Moderators" under my name? No? Then stop telling me about who you want to ban! I really don't care! Go bother a moderator.
SlugFiller rule #6: I can understand English, Hebrew, and a bit of Japanese(standard) and Chinese(mandarin), but if you speak to me in anything but English, do expect to be utterly ignored, at best.
0

#3 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 05 October 2005 - 10:38 AM

Oah *narf* I switch those 2:

Quote

bool CemuleApp::IsEd2kLinkInClipboard(LPCSTR pszLinkType, int iLinkTypeLen)
{
...
...
    // Use the ANSI string
    LPCSTR pszText = (LPCSTR)GlobalLock(hText);
    if (pszText != NULL)

0

  • Member Options

Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users