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. how to access bad pointers?

how to access bad pointers?

Scheduled Pinned Locked Moved C / C++ / MFC
databasetutorialquestion
7 Posts 6 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.
  • I Offline
    I Offline
    includeh10
    wrote on last edited by
    #1

    i worked in a company before. many apps shared to use a public database, the db (not SQL one) consisted lots of arrays, which hold pointers to some type of objects. unfortunately, some apps saved bad pointers (pointed to nothing but not null) to the db. once other apps accessed to those bad pointers, the apps crashed. do u know how to access to bad pointers with no crash (i.e. find they are bad then skip them)? thx includeh10

    M P P 3 Replies Last reply
    0
    • I includeh10

      i worked in a company before. many apps shared to use a public database, the db (not SQL one) consisted lots of arrays, which hold pointers to some type of objects. unfortunately, some apps saved bad pointers (pointed to nothing but not null) to the db. once other apps accessed to those bad pointers, the apps crashed. do u know how to access to bad pointers with no crash (i.e. find they are bad then skip them)? thx includeh10

      M Offline
      M Offline
      Michael P Butler
      wrote on last edited by
      #2

      Can you provide more detail on the file structure and details of what the crashes are. In the good old days of DOS, I used to have to manually fix bad pointers in files with a hex editor. Michael :-) Time flies like an arrow. Fruit flies like a banana

      I 1 Reply Last reply
      0
      • M Michael P Butler

        Can you provide more detail on the file structure and details of what the crashes are. In the good old days of DOS, I used to have to manually fix bad pointers in files with a hex editor. Michael :-) Time flies like an arrow. Fruit flies like a banana

        I Offline
        I Offline
        includeh10
        wrote on last edited by
        #3

        similar to this, i think: //the database is called "Object Store" //did by some one else MyClass p=new MyClass; delete p; ary.Add(p); //ary is an Array db.Save(); //Save to database //i do db.Open(file_name); int i,iNum=ary.GetSize(); for(i=0;i < iNum;i++) { int iSomeValue=ary.GetAt(i)->iSomeValue; } note: one of ary.GetAt(i) above gets bad pointer. thx includeh10

        M D 2 Replies Last reply
        0
        • I includeh10

          similar to this, i think: //the database is called "Object Store" //did by some one else MyClass p=new MyClass; delete p; ary.Add(p); //ary is an Array db.Save(); //Save to database //i do db.Open(file_name); int i,iNum=ary.GetSize(); for(i=0;i < iNum;i++) { int iSomeValue=ary.GetAt(i)->iSomeValue; } note: one of ary.GetAt(i) above gets bad pointer. thx includeh10

          M Offline
          M Offline
          mishgun
          wrote on last edited by
          #4

          Maybe you should derive all your classes from CObject and use IsKindOf? nobody is perfect

          1 Reply Last reply
          0
          • I includeh10

            similar to this, i think: //the database is called "Object Store" //did by some one else MyClass p=new MyClass; delete p; ary.Add(p); //ary is an Array db.Save(); //Save to database //i do db.Open(file_name); int i,iNum=ary.GetSize(); for(i=0;i < iNum;i++) { int iSomeValue=ary.GetAt(i)->iSomeValue; } note: one of ary.GetAt(i) above gets bad pointer. thx includeh10

            D Offline
            D Offline
            dlhson
            wrote on last edited by
            #5

            ;)That's your mistake. You should check your code before running Hung Son A Vietnamese student i-g.hypermart.net dlhson2001@yahoo.com

            1 Reply Last reply
            0
            • I includeh10

              i worked in a company before. many apps shared to use a public database, the db (not SQL one) consisted lots of arrays, which hold pointers to some type of objects. unfortunately, some apps saved bad pointers (pointed to nothing but not null) to the db. once other apps accessed to those bad pointers, the apps crashed. do u know how to access to bad pointers with no crash (i.e. find they are bad then skip them)? thx includeh10

              P Offline
              P Offline
              Philippe Mori
              wrote on last edited by
              #6

              You can check some bap pointers with a function like IsBadReadPtr and similar functions but it will not detect all bad pointers (and maybe none with our sample). You can also uses exception handling to catch access violation and do so other validation to ensure that the pointer do point to valid data. So any solution are a patch but when we want to handle corrupted files, we often have no choice than to fully validate the data and skip any data that does not appears to be good! Or if you can fix the data itself, simply correct existing files and create new files without corrupted data (you may in that case want to add some means to detect that you have a new file and skip validation in that case). Philippe Mori

              1 Reply Last reply
              0
              • I includeh10

                i worked in a company before. many apps shared to use a public database, the db (not SQL one) consisted lots of arrays, which hold pointers to some type of objects. unfortunately, some apps saved bad pointers (pointed to nothing but not null) to the db. once other apps accessed to those bad pointers, the apps crashed. do u know how to access to bad pointers with no crash (i.e. find they are bad then skip them)? thx includeh10

                P Offline
                P Offline
                Philip Patrick
                wrote on last edited by
                #7

                You can try to use AfxIsValidAddress, look up in MSDN on its parameters and explaination Philip Patrick Web-site: www.stpworks.com "Two beer or not two beer?" Shakesbeer

                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