Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Destructing an exception

Destructing an exception

Scheduled Pinned Locked Moved C / C++ / MFC
helpcomtoolsquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • RaviBeeR Offline
    RaviBeeR Offline
    RaviBee
    wrote on last edited by
    #1

    My app leaks a CArchiveException when an (expected) exception occurs. If I try to fix the leak by deleting the exception (using either [a] or [b]), the framework ASSERTs that the exception isn't ready for deletion. Any clues as to how I can fix the leak?

    status = Success;
    // CException* pExcToDelete = NULL;
    try {
    if (pArchive->IsStoring())
    (*pArchive) << m_tmLogin;
    else
    (*pArchive) >> m_tmLogin;
    }
    catch (CException* pExc) {
    // pExcToDelete = pExc;
    // delete pExcToDelete; <-- [a]
    status = Error;
    }
    // delete pExcToDelete; <-- [b]
    return (status);

    Thanks, /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

    A 1 Reply Last reply
    0
    • RaviBeeR RaviBee

      My app leaks a CArchiveException when an (expected) exception occurs. If I try to fix the leak by deleting the exception (using either [a] or [b]), the framework ASSERTs that the exception isn't ready for deletion. Any clues as to how I can fix the leak?

      status = Success;
      // CException* pExcToDelete = NULL;
      try {
      if (pArchive->IsStoring())
      (*pArchive) << m_tmLogin;
      else
      (*pArchive) >> m_tmLogin;
      }
      catch (CException* pExc) {
      // pExcToDelete = pExc;
      // delete pExcToDelete; <-- [a]
      status = Error;
      }
      // delete pExcToDelete; <-- [b]
      return (status);

      Thanks, /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      A Offline
      A Offline
      Artem Moroz
      wrote on last edited by
      #2

      call pExc->Delete() inside catch block

      RaviBeeR 1 Reply Last reply
      0
      • A Artem Moroz

        call pExc->Delete() inside catch block

        RaviBeeR Offline
        RaviBeeR Offline
        RaviBee
        wrote on last edited by
        #3

        Ahh... thanks! :rose: /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups