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. pointer error

pointer error

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiodebugginghelp
8 Posts 7 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.
  • N Offline
    N Offline
    Ni m
    wrote on last edited by
    #1

    char *sendSize; sendSize = new char[10]; //on operator delete i have error during the running: //Unhandled exception at 0x77f767cd in Connect.exe: User //breakpoint. // in dbgheap.h // #define WINVER 0x0400 // I'm using VS 7. delete [] sendSize;

    P C V B 4 Replies Last reply
    0
    • N Ni m

      char *sendSize; sendSize = new char[10]; //on operator delete i have error during the running: //Unhandled exception at 0x77f767cd in Connect.exe: User //breakpoint. // in dbgheap.h // #define WINVER 0x0400 // I'm using VS 7. delete [] sendSize;

      P Offline
      P Offline
      Prakash Nadar
      wrote on last edited by
      #2

      there must be something you must be doing between new and delete that is causing the problem with the pointer. if you overshoot the buffer you would get the error when deleting the pointer.


      I'll write a suicide note on a hundred dollar bill - Dire Straits

      D 1 Reply Last reply
      0
      • N Ni m

        char *sendSize; sendSize = new char[10]; //on operator delete i have error during the running: //Unhandled exception at 0x77f767cd in Connect.exe: User //breakpoint. // in dbgheap.h // #define WINVER 0x0400 // I'm using VS 7. delete [] sendSize;

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        Be sure you don't write outside the border of your allocated memory (be carefull of the end of string character ('\0') ). So this will probably produce an exception when destroying the string: char* sendSize; sendSize = new char[10]; strcpy(sendSize,"1234567899"); //'\0'will be added to end of string

        1 Reply Last reply
        0
        • P Prakash Nadar

          there must be something you must be doing between new and delete that is causing the problem with the pointer. if you overshoot the buffer you would get the error when deleting the pointer.


          I'll write a suicide note on a hundred dollar bill - Dire Straits

          D Offline
          D Offline
          Dennis Gourjii
          wrote on last edited by
          #4

          Weird... I had that one too a while ago and it seemingly had nothing to do with pointers. This is just that there is a particular breakpoint code in executable. Can this be a compiler bug because it all went away as soon as I switched to Release build. PS. It's not an "overshoot" error. The error message sounds differently. I remember because I get it at times :)

          T 1 Reply Last reply
          0
          • D Dennis Gourjii

            Weird... I had that one too a while ago and it seemingly had nothing to do with pointers. This is just that there is a particular breakpoint code in executable. Can this be a compiler bug because it all went away as soon as I switched to Release build. PS. It's not an "overshoot" error. The error message sounds differently. I remember because I get it at times :)

            T Offline
            T Offline
            Tim Smith
            wrote on last edited by
            #5

            You are still trashing memory outside of the array. The reason it doesn't have problems in release mode is because the CRTL doesn't have the memory checks on deallocation. All you did was turn off the error, not fix it. Tim Smith I'm going to patent thought. I have yet to see any prior art.

            D 1 Reply Last reply
            0
            • N Ni m

              char *sendSize; sendSize = new char[10]; //on operator delete i have error during the running: //Unhandled exception at 0x77f767cd in Connect.exe: User //breakpoint. // in dbgheap.h // #define WINVER 0x0400 // I'm using VS 7. delete [] sendSize;

              V Offline
              V Offline
              valikac
              wrote on last edited by
              #6

              Try setting the last item in the array to null. Kuphryn

              1 Reply Last reply
              0
              • N Ni m

                char *sendSize; sendSize = new char[10]; //on operator delete i have error during the running: //Unhandled exception at 0x77f767cd in Connect.exe: User //breakpoint. // in dbgheap.h // #define WINVER 0x0400 // I'm using VS 7. delete [] sendSize;

                B Offline
                B Offline
                bikram singh
                wrote on last edited by
                #7

                See the line dbgheap.h which is showing an error. It can tell you a lot about the failure. Bikram Singh

                1 Reply Last reply
                0
                • T Tim Smith

                  You are still trashing memory outside of the array. The reason it doesn't have problems in release mode is because the CRTL doesn't have the memory checks on deallocation. All you did was turn off the error, not fix it. Tim Smith I'm going to patent thought. I have yet to see any prior art.

                  D Offline
                  D Offline
                  Dennis Gourjii
                  wrote on last edited by
                  #8

                  Yup. This can be true. But the other possibility is that there actually is no error and Debug version just keeps generating that lousy exception because I'm trying to write beyond what's the end of the string (i.e. '\0') but far from being beyond the end of the allocated memory end. In such case it can be but a misunderstanding based on compiler developers' wish to warn programmer of a possible mistake. If it's an actual error then please somebody explain to me what's wrong with this code: char* ptr=new char[256]; strcpy(ptr,"123"); ptr[3]='4'; ptr[4]='\0'; delete [] char; //we get an exception here

                  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