Click here to Skip to main content
15,867,330 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionwhat I am doing regarding Heap corruption Pin
ForNow10-Jan-23 15:33
ForNow10-Jan-23 15:33 
AnswerRe: what I am doing regarding Heap corruption Pin
CPallini10-Jan-23 20:08
mveCPallini10-Jan-23 20:08 
GeneralRe: what I am doing regarding Heap corruption Pin
ForNow11-Jan-23 1:33
ForNow11-Jan-23 1:33 
GeneralRe: what I am doing regarding Heap corruption Pin
CPallini11-Jan-23 1:40
mveCPallini11-Jan-23 1:40 
GeneralRe: what I am doing regarding Heap corruption Pin
Mircea Neacsu11-Jan-23 7:04
Mircea Neacsu11-Jan-23 7:04 
GeneralRe: what I am doing regarding Heap corruption Pin
ForNow11-Jan-23 7:25
ForNow11-Jan-23 7:25 
QuestionHeap Storage Corruption Pin
ForNow10-Jan-23 3:44
ForNow10-Jan-23 3:44 
AnswerRe: Heap Storage Corruption Pin
Victor Nijegorodov10-Jan-23 5:08
Victor Nijegorodov10-Jan-23 5:08 
ForNow wrote:
C++
s = new char[63];
::memcpy(s, t, 62);
k = s + 62;
::memcpy(k, &thenullptr, 1);    <------- call which causes read exception or overwrite

why are you doing it so complicated?
Why not just
C++
s = new char[63] {0};
::memcpy(s, t, 62);
and you won't need to copy the terminated 0x00 byte.
Or just set it form the very begin:
C++
s = new char[63];
s[62] = '\0';
::memcpy(s, t, 62);


modified 10-Jan-23 11:17am.

GeneralRe: Heap Storage Corruption Pin
ForNow10-Jan-23 5:25
ForNow10-Jan-23 5:25 
GeneralRe: Heap Storage Corruption Pin
k505410-Jan-23 6:17
mvek505410-Jan-23 6:17 
AnswerRe: Heap Storage Corruption Pin
Graham Breach10-Jan-23 6:22
Graham Breach10-Jan-23 6:22 
GeneralRe: Heap Storage Corruption Pin
ForNow10-Jan-23 6:44
ForNow10-Jan-23 6:44 
GeneralRe: Heap Storage Corruption Pin
Graham Breach10-Jan-23 6:51
Graham Breach10-Jan-23 6:51 
AnswerRe: Heap Storage Corruption Pin
CPallini10-Jan-23 7:21
mveCPallini10-Jan-23 7:21 
GeneralRe: Heap Storage Corruption Pin
ForNow10-Jan-23 7:26
ForNow10-Jan-23 7:26 
GeneralRe: Heap Storage Corruption Pin
CPallini10-Jan-23 7:40
mveCPallini10-Jan-23 7:40 
AnswerRe: Heap Storage Corruption Pin
CPallini10-Jan-23 8:32
mveCPallini10-Jan-23 8:32 
QuestionTo be deleted... Pin
arnold_w10-Jan-23 1:01
arnold_w10-Jan-23 1:01 
SuggestionRe: Why isn't my semi-editable ComboBox drawing the text in gray when the dropdown list isn't showing? Pin
Richard Deeming10-Jan-23 2:03
mveRichard Deeming10-Jan-23 2:03 
QuestionRe: Why isn't my semi-editable ComboBox drawing the text in gray when the dropdown list isn't showing? Pin
David Crow10-Jan-23 2:07
David Crow10-Jan-23 2:07 
QuestionTrying to Disable string operator= Pin
ForNow8-Jan-23 16:55
ForNow8-Jan-23 16:55 
AnswerRe: Trying to Disable string operator= Pin
k50548-Jan-23 17:49
mvek50548-Jan-23 17:49 
GeneralRe: Trying to Disable string operator= Pin
ForNow8-Jan-23 18:02
ForNow8-Jan-23 18:02 
AnswerRe: Trying to Disable string operator= Pin
Victor Nijegorodov8-Jan-23 22:50
Victor Nijegorodov8-Jan-23 22:50 
GeneralRe: Trying to Disable string operator= Pin
ForNow9-Jan-23 3:18
ForNow9-Jan-23 3:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.