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. Memory Overwrite

Memory Overwrite

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structuresperformancehelp
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.
  • V Offline
    V Offline
    vilmer
    wrote on last edited by
    #1

    Hi, I have noticed a strange behaviour in my app. I have 4 staic items: static char* manuf[512]; static int link_man[512]; static char* comp[128]; static CDatasheet DS; where CDatasheet is a class derived from CObject. Filling in the manuf array, when I reach the 264th item, the app starts overwriting the memory space allocated for the DS object. So any assignment operation to that object produces an error. Any suggestion? Another question: I tried to remove the DS object (commented out), but the compiler still build the app. I parsed all my files, but there are no other declaration for that object. What can it be happened? Thanks Dwarfpower

    C 1 Reply Last reply
    0
    • V vilmer

      Hi, I have noticed a strange behaviour in my app. I have 4 staic items: static char* manuf[512]; static int link_man[512]; static char* comp[128]; static CDatasheet DS; where CDatasheet is a class derived from CObject. Filling in the manuf array, when I reach the 264th item, the app starts overwriting the memory space allocated for the DS object. So any assignment operation to that object produces an error. Any suggestion? Another question: I tried to remove the DS object (commented out), but the compiler still build the app. I parsed all my files, but there are no other declaration for that object. What can it be happened? Thanks Dwarfpower

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

      vilmer wrote: static char* manuf[512]; vilmer wrote: Filling in the manuf array, when I reach the 264th item, the app starts overwriting the memory space allocated for the DS object. So any assignment operation to that object produces an error. How are you filling the array ? You know that manuf is an array of pointers, and not a string ? You have an array of 512 'strings' that are undefined (that is all adresses are invalid at the begining). Post the code, so maybe we can help you.

      V 1 Reply Last reply
      0
      • C Cedric Moonen

        vilmer wrote: static char* manuf[512]; vilmer wrote: Filling in the manuf array, when I reach the 264th item, the app starts overwriting the memory space allocated for the DS object. So any assignment operation to that object produces an error. How are you filling the array ? You know that manuf is an array of pointers, and not a string ? You have an array of 512 'strings' that are undefined (that is all adresses are invalid at the begining). Post the code, so maybe we can help you.

        V Offline
        V Offline
        vilmer
        wrote on last edited by
        #3

        Code is manuf[i] = strdup("Hello"); the function provides to create a location of memory where it copies the string and writes the address of that location on the pointer manuf[i]

        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