Click here to Skip to main content
15,892,575 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Why "so many " - include , forward declaration... Pin
CPallini14-Jan-23 7:23
mveCPallini14-Jan-23 7:23 
AnswerRe: Why "so many " - include , forward declaration... Pin
Richard MacCutchan14-Jan-23 22:25
mveRichard MacCutchan14-Jan-23 22:25 
AnswerRe: Why "so many " - include , forward declaration... Pin
jschell15-Jan-23 8:00
jschell15-Jan-23 8:00 
GeneralMessage Closed Pin
15-Jan-23 16:56
Member 1496877115-Jan-23 16:56 
GeneralRe: Why "so many " - include , forward declaration... Pin
jschell17-Jan-23 3:33
jschell17-Jan-23 3:33 
QuestionCRichEditCtrl size limit Pin
ForNow11-Jan-23 15:22
ForNow11-Jan-23 15:22 
AnswerRe: CRichEditCtrl size limit Pin
Mircea Neacsu11-Jan-23 15:47
Mircea Neacsu11-Jan-23 15:47 
GeneralRe: CRichEditCtrl size limit Pin
ForNow11-Jan-23 15:48
ForNow11-Jan-23 15:48 
QuestionBitmaps, device dependent vs device independent, which is faster (or better)? Pin
Member 1507871611-Jan-23 10:57
Member 1507871611-Jan-23 10:57 
AnswerRe: Bitmaps, device dependent vs device independent, which is faster (or better)? Pin
CPallini11-Jan-23 20:43
mveCPallini11-Jan-23 20:43 
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 
Hi
I have the following code which I basically take a hex array and convert it to a ascii char * e.g 0X47F0F01A so the array becomes 303770307030316500
I marked off where I get dialogbox message from CRT and I cannt for the life of me figure out why
the memcpy where I mark off the string with a null is 8 bytes into the 70 bytes allocated

C++
// converts character array
// to string and returns it
char* convertToString(unsigned char* a, int size)
{
    int i;
    char ch;
    char getch(char);
    char* t = new char[70];
    char* k = t;
    char thenullptr = 0x00;
    char* s;
    if (size == 80)
        __debugbreak();
    for (i = 0; (i < size && i < 62); i++) {
        ch = a[i];
        ch = ch >> 4;
        ch = ch & 0x0f;
        ch = getch(ch);
        memcpy(k, &ch, 1);
        k++;
        ch = a[i];
        ch = ch & 0x0f;
        ch = getch(ch);
        memcpy(k, &ch, 1);
        k++;

    }
    if (i >= 62)
    {
        s = new char[63];
        ::memcpy(s, t, 62);
        k = s + 62;
        ::memcpy(k, &thenullptr, 1);    <------- call which causes read exception or overwrite

        delete t;
        return s;
    }


    ::memcpy(k, &thenullptr, 1);
    s = new char(strlen(t) + 1);
;
    ::memcpy(s, t, strlen(t) + 1);
    delete t;
    return s;
}

char getch(char ch)
{

    if (ch <= 0x09)
        ch += 48;
    else
        ch += 55;
    return ch;
}

AnswerRe: Heap Storage Corruption Pin
Victor Nijegorodov10-Jan-23 5:08
Victor Nijegorodov10-Jan-23 5:08 
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 

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.