Click here to Skip to main content
15,611,970 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 

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.