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. Strange Error during execution

Strange Error during execution

Scheduled Pinned Locked Moved C / C++ / MFC
helpdata-structuresquestion
3 Posts 3 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.
  • P Offline
    P Offline
    Paolo Ponzano
    wrote on last edited by
    #1

    Hello, I'm getting this error: Run-Time Check Failure #2 - Stack around the variable 'UniqueID' was corrupted. Here's the function that generates it __declspec( dllexport ) BYTE* LaunchMe(BYTE* id) { SERIAL *serial=NULL; BYTE ProductID[BUFFER_LENGHT]; BYTE UniqueID[16]; char *ProductID_Processed=(char*)malloc(BUFFER_LENGHT); serial=(SERIAL*)malloc(sizeof(SERIAL)); memset(serial, 0, sizeof(SERIAL)); memset(&ProductID, 0, BUFFER_LENGHT); memset(&UniqueID, 0, 24); getHardDriveComputerID (serial); if ( GetProductID(ProductID, BUFFER_LENGHT) == false) return false; ProductID_Processed=ProcessProductID(ProductID, BUFFER_LENGHT); if (ProductID_Processed == NULL) return false; CalculateUniqueID(serial->serial, ProductID_Processed,UniqueID); memcpy(id, UniqueID, 16); return NULL; } Which is the cause of that error? What "around" means?? I get this error some other time also, and google wasn't able to help me, thanks in advance Paolo

    I M 2 Replies Last reply
    0
    • P Paolo Ponzano

      Hello, I'm getting this error: Run-Time Check Failure #2 - Stack around the variable 'UniqueID' was corrupted. Here's the function that generates it __declspec( dllexport ) BYTE* LaunchMe(BYTE* id) { SERIAL *serial=NULL; BYTE ProductID[BUFFER_LENGHT]; BYTE UniqueID[16]; char *ProductID_Processed=(char*)malloc(BUFFER_LENGHT); serial=(SERIAL*)malloc(sizeof(SERIAL)); memset(serial, 0, sizeof(SERIAL)); memset(&ProductID, 0, BUFFER_LENGHT); memset(&UniqueID, 0, 24); getHardDriveComputerID (serial); if ( GetProductID(ProductID, BUFFER_LENGHT) == false) return false; ProductID_Processed=ProcessProductID(ProductID, BUFFER_LENGHT); if (ProductID_Processed == NULL) return false; CalculateUniqueID(serial->serial, ProductID_Processed,UniqueID); memcpy(id, UniqueID, 16); return NULL; } Which is the cause of that error? What "around" means?? I get this error some other time also, and google wasn't able to help me, thanks in advance Paolo

      I Offline
      I Offline
      Indrawati
      wrote on last edited by
      #2

      Don't know whether this is the same as your case, but I once had a similar problem and it turned out the cause is because of stack overflow. Maybe you can check whether you have enough stack space to hold ProductID? What's the value of BUFFER_LENGTH?

      1 Reply Last reply
      0
      • P Paolo Ponzano

        Hello, I'm getting this error: Run-Time Check Failure #2 - Stack around the variable 'UniqueID' was corrupted. Here's the function that generates it __declspec( dllexport ) BYTE* LaunchMe(BYTE* id) { SERIAL *serial=NULL; BYTE ProductID[BUFFER_LENGHT]; BYTE UniqueID[16]; char *ProductID_Processed=(char*)malloc(BUFFER_LENGHT); serial=(SERIAL*)malloc(sizeof(SERIAL)); memset(serial, 0, sizeof(SERIAL)); memset(&ProductID, 0, BUFFER_LENGHT); memset(&UniqueID, 0, 24); getHardDriveComputerID (serial); if ( GetProductID(ProductID, BUFFER_LENGHT) == false) return false; ProductID_Processed=ProcessProductID(ProductID, BUFFER_LENGHT); if (ProductID_Processed == NULL) return false; CalculateUniqueID(serial->serial, ProductID_Processed,UniqueID); memcpy(id, UniqueID, 16); return NULL; } Which is the cause of that error? What "around" means?? I get this error some other time also, and google wasn't able to help me, thanks in advance Paolo

        M Offline
        M Offline
        mahade1
        wrote on last edited by
        #3

        Hi, The problem is pretty straight forward. You are declaring UniqueId[16] and in memset you are using 24. Change it to memset(UniqueID, 0, 16); That should solve the problem. Regards, Mahadevan

        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