Skip to content

Leak of memory for BSTR friendlyName due to missing call to SysFreeString #4

Description

@JohnLaTwC

A BSTR friendlyName is declared but not freed in the main body of getAppDomain and the memory is leaked as a result

    while((hr = icrh->NextDomain(hDomainEnum, &iu)) == S_OK){

!        BSTR friendlyName;   <<< BSTR declared

...

!        hr = appDomain->get_FriendlyName(&friendlyName);   <<< BSTR allocated and returned

        if(friendlyName && wcscmp(friendlyName, appDomainName) == 0){
            iu->Release();
            found = true;
+            SysFreeString on friendlyName
            break;
        }

        hr = appDomain->Load_2(SysAllocString(L"BOFNET"), &assembly);

        if(assembly == nullptr){
            iu->Release();
+            SysFreeString on friendlyName
            continue;
        }

        found = true;
        iu->Release();
+            SysFreeString on friendlyName
        break;
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions