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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Bad pointer

Bad pointer

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 5 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.
  • S Offline
    S Offline
    Stefan Spenz
    wrote on last edited by
    #1

    Hi, in a particular situation, my pointer pManager becomes somewhat faulty. It passes the if (pManager) { check, but most of the members are not active and the code crashes when I try to access them. Now, I want to check if a particular member inside the pointer is valid. When I try like this if (pManager->bMember) {, the code crashes. Are there any functions to check the integrity of a member? Regards, Stefan

    S T H G 4 Replies Last reply
    0
    • S Stefan Spenz

      Hi, in a particular situation, my pointer pManager becomes somewhat faulty. It passes the if (pManager) { check, but most of the members are not active and the code crashes when I try to access them. Now, I want to check if a particular member inside the pointer is valid. When I try like this if (pManager->bMember) {, the code crashes. Are there any functions to check the integrity of a member? Regards, Stefan

      S Offline
      S Offline
      Sarath C
      wrote on last edited by
      #2

      Stefan Spenz wrote:

      When I try like this if (pManager->bMember)

      pManager itself is invalid that is why the error occurs. You can use IsBadReadPtr,IsBadWritePtr according to your requirement. But you could handle the situation without these functions.

      SaRath.
      _"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"


      My Blog | Understanding State Pattern_

      1 Reply Last reply
      0
      • S Stefan Spenz

        Hi, in a particular situation, my pointer pManager becomes somewhat faulty. It passes the if (pManager) { check, but most of the members are not active and the code crashes when I try to access them. Now, I want to check if a particular member inside the pointer is valid. When I try like this if (pManager->bMember) {, the code crashes. Are there any functions to check the integrity of a member? Regards, Stefan

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        do you construct the object correctly, and how to you assign pManager ?


        TOXCCT >>> GEII power

        [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

        1 Reply Last reply
        0
        • S Stefan Spenz

          Hi, in a particular situation, my pointer pManager becomes somewhat faulty. It passes the if (pManager) { check, but most of the members are not active and the code crashes when I try to access them. Now, I want to check if a particular member inside the pointer is valid. When I try like this if (pManager->bMember) {, the code crashes. Are there any functions to check the integrity of a member? Regards, Stefan

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          How do you declare pManagerCan you show

          _**


          **_

          WhiteSky


          1 Reply Last reply
          0
          • S Stefan Spenz

            Hi, in a particular situation, my pointer pManager becomes somewhat faulty. It passes the if (pManager) { check, but most of the members are not active and the code crashes when I try to access them. Now, I want to check if a particular member inside the pointer is valid. When I try like this if (pManager->bMember) {, the code crashes. Are there any functions to check the integrity of a member? Regards, Stefan

            G Offline
            G Offline
            Gary R Wheeler
            wrote on last edited by
            #5

            If the pointer pManager was never initialized using

            pManager = new Manager(); // or whatever the class name is

            that will cause this problem. If the pointer pManager was initialized but now causes an access violation, it probably means the you have issued a "delete pManager;" at some point. pManager now points to memory you no longer own.


            Software Zen: delete this;

            Fold With Us![^]

            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