FIX: SetData Always Returns E_OUTOFMEMORY

Last reviewed: September 18, 1997
Article ID: Q121522
1.50 1.51 WINDOWS kbole kbfixlist kbbuglist kbprg kbtshoot

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC) included with

        - Microsoft Visual C++ for Windows, versions 1.5 and 1.51
    

SYMPTOMS

Any call to COleServerDoc::XDataObject::SetData will return the HRESULT corresponding to the error SCODE E_OUTOFMEMORY.

CAUSE

This is due to a missing line in the source code's TRY block that should set sc=S_OK if no exception is thrown.

RESOLUTION

Add the line sc=S_OK to the end of the TRY block in the code sample shown in the More Information section. (Currently, the sc=S_OK line appears as a comment in the sample code.) Then and recompile the MFC libraries using the supplied MAKEFILE in the \MSVC\MFC\SRC directory of your Visual C++ installation.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ 1.52 for Windows.

REFERENCES

Sample Code

/* Compile options needed:
*/
STDMETHODIMP COleServerDoc::XDataObject::SetData(
     LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium, BOOL fRelease)
{
     METHOD_PROLOGUE(COleServerDoc, DataObject)
     ASSERT_VALID(pThis);

     COleServerItem* pItem;
     SCODE sc = E_OUTOFMEMORY;
     TRY
     {
          pItem = pThis->GetEmbeddedItem();
          ASSERT_VALID(pItem);
          ASSERT(pItem->IsKindOf(RUNTIME_CLASS(COleServerItem)));
          // missing sc=S_OK; here
     }
     END_TRY

     if (sc != S_OK)
          return ResultFromScode(sc);

     return pItem->GetDataObject()->SetData(lpFormatEtc,
          lpStgMedium,fRelease);
}


Additional reference words: 1.50 1.51 2.50 2.51
KBCategory: kbole kbfixlist kbbuglist kbprg kbtshoot
KBSubcategory: MfcOLE
Keywords : MfcOLE kbbuglist kbfixlist kbole kbprg kbtshoot
Technology : kbMfc
Version : 1.50 1.51
Platform : WINDOWS
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.