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. The Lounge
  3. Viewers of a nervous disposition should look away now

Viewers of a nervous disposition should look away now

Scheduled Pinned Locked Moved The Lounge
help
15 Posts 9 Posters 1 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    A recent post was about OP's code getting a crtisvalidheappointer error in a C code program. The code was using malloc/calloc and free, so it was a fair guess what was going wrong. One or two answers and comments were posted with the usual suggestions. The OP then posted the following:

    Quote:

    thanks but I solved in this way: if (pchTesto != NULL) { pchTesto = NULL; delete pchTesto; } if (pchBuffOut != NULL) { pchBuffOut = NULL; delete pchBuffOut; }

    :omg:

    D H CPalliniC C S 5 Replies Last reply
    0
    • L Lost User

      A recent post was about OP's code getting a crtisvalidheappointer error in a C code program. The code was using malloc/calloc and free, so it was a fair guess what was going wrong. One or two answers and comments were posted with the usual suggestions. The OP then posted the following:

      Quote:

      thanks but I solved in this way: if (pchTesto != NULL) { pchTesto = NULL; delete pchTesto; } if (pchBuffOut != NULL) { pchBuffOut = NULL; delete pchBuffOut; }

      :omg:

      D Offline
      D Offline
      den2k88
      wrote on last edited by
      #2

      Big whoopsie moment, I had a few of them, enugh that I made my own macro DDELETENULL(x) to avoid the same mistake.

      #define DDELETENULL(x) if (x != NULL) {delete(x); x = NULL;}

      I had a DFREENULL(x) which was identical but with free.

      GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X The shortest horror story: On Error Resume Next

      Mircea NeacsuM 1 Reply Last reply
      0
      • L Lost User

        A recent post was about OP's code getting a crtisvalidheappointer error in a C code program. The code was using malloc/calloc and free, so it was a fair guess what was going wrong. One or two answers and comments were posted with the usual suggestions. The OP then posted the following:

        Quote:

        thanks but I solved in this way: if (pchTesto != NULL) { pchTesto = NULL; delete pchTesto; } if (pchBuffOut != NULL) { pchBuffOut = NULL; delete pchBuffOut; }

        :omg:

        H Offline
        H Offline
        honey the codewitch
        wrote on last edited by
        #3

        I have a lot of counterproductive instincts, but ones that I do have that I really appreciate are the ones that carry me through doing pointer operations. It's second nature, and I don't screw it up nearly as much as I deserve to.

        There's smoke in my iris But I painted a sunny day on the insides of my eyelids So I'm ready now (What you ready for?) I'm ready for life in this city And my wings have grown almost enough to lift me

        1 Reply Last reply
        0
        • L Lost User

          A recent post was about OP's code getting a crtisvalidheappointer error in a C code program. The code was using malloc/calloc and free, so it was a fair guess what was going wrong. One or two answers and comments were posted with the usual suggestions. The OP then posted the following:

          Quote:

          thanks but I solved in this way: if (pchTesto != NULL) { pchTesto = NULL; delete pchTesto; } if (pchBuffOut != NULL) { pchBuffOut = NULL; delete pchBuffOut; }

          :omg:

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          "making good use of the commutative property of the delete operator" :laugh: :laugh: :laugh:

          "In testa che avete, Signor di Ceprano?" -- Rigoletto

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • L Lost User

            A recent post was about OP's code getting a crtisvalidheappointer error in a C code program. The code was using malloc/calloc and free, so it was a fair guess what was going wrong. One or two answers and comments were posted with the usual suggestions. The OP then posted the following:

            Quote:

            thanks but I solved in this way: if (pchTesto != NULL) { pchTesto = NULL; delete pchTesto; } if (pchBuffOut != NULL) { pchBuffOut = NULL; delete pchBuffOut; }

            :omg:

            C Offline
            C Offline
            charlieg
            wrote on last edited by
            #5

            wow. reminds me of the time when a coworker, who was a bit of a PITA - never listened to good advice, was convinced he had found a bug in the compiler. Having had this fantasy once or twice myself, I've learned that it is almost certainly not the compilier :). Myself and one other took a look at his code and immediately found a buffer overrun. He insisted that it always worked correctly before and that could not be the issue. but back to that code fragment - :omg:

            Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

            Mircea NeacsuM D J 3 Replies Last reply
            0
            • D den2k88

              Big whoopsie moment, I had a few of them, enugh that I made my own macro DDELETENULL(x) to avoid the same mistake.

              #define DDELETENULL(x) if (x != NULL) {delete(x); x = NULL;}

              I had a DFREENULL(x) which was identical but with free.

              GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X The shortest horror story: On Error Resume Next

              Mircea NeacsuM Online
              Mircea NeacsuM Online
              Mircea Neacsu
              wrote on last edited by
              #6

              My dear Watson, it's pretty sure DFREENULL(x) came before the DDELETENULL(x) and the if statement got carried away. In C++ you can delete NULL pointers without hearing a peep from the compiler. :laugh:

              Mircea

              D 1 Reply Last reply
              0
              • Mircea NeacsuM Mircea Neacsu

                My dear Watson, it's pretty sure DFREENULL(x) came before the DDELETENULL(x) and the if statement got carried away. In C++ you can delete NULL pointers without hearing a peep from the compiler. :laugh:

                Mircea

                D Offline
                D Offline
                den2k88
                wrote on last edited by
                #7

                First, it was C++/98, mostly (VisualStudio 6, in 201x, ugh) and it would create issues. Second, I do clean programming. If a pointer is NULL I don't delete it, despite what the compiler says. It's simply wrong. Third, DDELETENULL came first because I needed it before I realized I also had some pointers to deallocate with free (mostly the ones allocated with _mm_malloc).

                GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X The shortest horror story: On Error Resume Next

                1 Reply Last reply
                0
                • C charlieg

                  wow. reminds me of the time when a coworker, who was a bit of a PITA - never listened to good advice, was convinced he had found a bug in the compiler. Having had this fantasy once or twice myself, I've learned that it is almost certainly not the compilier :). Myself and one other took a look at his code and immediately found a buffer overrun. He insisted that it always worked correctly before and that could not be the issue. but back to that code fragment - :omg:

                  Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                  Mircea NeacsuM Online
                  Mircea NeacsuM Online
                  Mircea Neacsu
                  wrote on last edited by
                  #8

                  charlieg wrote:

                  Having had this fantasy once or twice myself,

                  At one point I put a PostIt note on my monitor: "The stupid is on the other side of the screen" :laugh:

                  Mircea

                  K 1 Reply Last reply
                  0
                  • C charlieg

                    wow. reminds me of the time when a coworker, who was a bit of a PITA - never listened to good advice, was convinced he had found a bug in the compiler. Having had this fantasy once or twice myself, I've learned that it is almost certainly not the compilier :). Myself and one other took a look at his code and immediately found a buffer overrun. He insisted that it always worked correctly before and that could not be the issue. but back to that code fragment - :omg:

                    Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                    D Offline
                    D Offline
                    den2k88
                    wrote on last edited by
                    #9

                    In the embedded world sometimes we actually find bugs in the compiler, though they are easier to spot since the disassembly is much leaner.

                    GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X The shortest horror story: On Error Resume Next

                    C 1 Reply Last reply
                    0
                    • L Lost User

                      A recent post was about OP's code getting a crtisvalidheappointer error in a C code program. The code was using malloc/calloc and free, so it was a fair guess what was going wrong. One or two answers and comments were posted with the usual suggestions. The OP then posted the following:

                      Quote:

                      thanks but I solved in this way: if (pchTesto != NULL) { pchTesto = NULL; delete pchTesto; } if (pchBuffOut != NULL) { pchBuffOut = NULL; delete pchBuffOut; }

                      :omg:

                      S Offline
                      S Offline
                      Single Step Debugger
                      wrote on last edited by
                      #10

                      It's like taking leak in the morning and then waking up.

                      Advertise here – minimum three posts per day are guaranteed.

                      1 Reply Last reply
                      0
                      • D den2k88

                        In the embedded world sometimes we actually find bugs in the compiler, though they are easier to spot since the disassembly is much leaner.

                        GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X The shortest horror story: On Error Resume Next

                        C Offline
                        C Offline
                        charlieg
                        wrote on last edited by
                        #11

                        I have heard of this happening but never experienced it. This had to do with the C compiler for OpenVMS. The people that worked on DEC's compilers were legendary.

                        Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                        1 Reply Last reply
                        0
                        • C charlieg

                          wow. reminds me of the time when a coworker, who was a bit of a PITA - never listened to good advice, was convinced he had found a bug in the compiler. Having had this fantasy once or twice myself, I've learned that it is almost certainly not the compilier :). Myself and one other took a look at his code and immediately found a buffer overrun. He insisted that it always worked correctly before and that could not be the issue. but back to that code fragment - :omg:

                          Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                          J Offline
                          J Offline
                          jschell
                          wrote on last edited by
                          #12

                          charlieg wrote:

                          he had found a bug in the compiler. Having had this fantasy once or twice myself, I've learned that it is almost certainly not the compilier

                          Very long time ago I found a bug in the C++ compiler I was using. So I wrote a letter to the company (again long time ago.) I carefully pointed out how the C++ compiler did not do what Stroustrup documented in "The C++ Programming Language". The president of the company (I suspect the only employee) wrote back to tell me that Stroustrup was wrong. Years later when the ANSI C++ spec was finalized I saw that Stroustrup was still right.

                          C 1 Reply Last reply
                          0
                          • Mircea NeacsuM Mircea Neacsu

                            charlieg wrote:

                            Having had this fantasy once or twice myself,

                            At one point I put a PostIt note on my monitor: "The stupid is on the other side of the screen" :laugh:

                            Mircea

                            K Offline
                            K Offline
                            Kelly Herald
                            wrote on last edited by
                            #13

                            I usually refer to the acronym PICNIC. Problem In Chair Not In Computer

                            Kelly Herald Software Developer

                            Mircea NeacsuM 1 Reply Last reply
                            0
                            • K Kelly Herald

                              I usually refer to the acronym PICNIC. Problem In Chair Not In Computer

                              Kelly Herald Software Developer

                              Mircea NeacsuM Online
                              Mircea NeacsuM Online
                              Mircea Neacsu
                              wrote on last edited by
                              #14

                              I knew it as PBKAC[^] but I like your acronym better :laugh: My formulation leaves a chance to sensitive souls to imagine that problem is behind the screen... as if ;P

                              Mircea

                              1 Reply Last reply
                              0
                              • J jschell

                                charlieg wrote:

                                he had found a bug in the compiler. Having had this fantasy once or twice myself, I've learned that it is almost certainly not the compilier

                                Very long time ago I found a bug in the C++ compiler I was using. So I wrote a letter to the company (again long time ago.) I carefully pointed out how the C++ compiler did not do what Stroustrup documented in "The C++ Programming Language". The president of the company (I suspect the only employee) wrote back to tell me that Stroustrup was wrong. Years later when the ANSI C++ spec was finalized I saw that Stroustrup was still right.

                                C Offline
                                C Offline
                                charlieg
                                wrote on last edited by
                                #15

                                priceless. That guy has some brass balls.

                                Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                                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