{"id":312,"date":"2010-09-30T09:56:17","date_gmt":"2010-09-30T14:56:17","guid":{"rendered":"http:\/\/www.jaimerios.com\/?p=312"},"modified":"2010-09-30T09:56:17","modified_gmt":"2010-09-30T14:56:17","slug":"heap-corruption-on-pc-with-const-char","status":"publish","type":"post","link":"https:\/\/jaimerios.com\/?p=312","title":{"rendered":"HEAP corruption on PC with const char*"},"content":{"rendered":"<p>I had a weird thing happen where if I create a TCHAR variable[MAX_PATH] and populate that using any Win32 function, then take that variable and memcpy it into a const char * that has been new&#8217;d, I get a HEAP corruption message when I call delete[] on the const char *.<\/p>\n<p>Now the funny thing is&#8230; if I change out the memcpy for strcpy, the HEAP corruption message goes away in debug mode, however, if I use strncpy, I get the HEAP corruption message again.<\/p>\n<p>Weird.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had a weird thing happen where if I create a TCHAR variable[MAX_PATH] and populate that using any Win32 function, then take that variable and memcpy it into a const char * that has been new&#8217;d, I get a HEAP corruption message when I call delete[] on the const char *. Now the funny thing &#8230; <a title=\"HEAP corruption on PC with const char*\" class=\"read-more\" href=\"https:\/\/jaimerios.com\/?p=312\" aria-label=\"Read more about HEAP corruption on PC with const char*\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[100,294,425],"class_list":["post-312","post","type-post","status-publish","format-standard","hentry","category-coding","tag-c","tag-max_path","tag-strcpy"],"_links":{"self":[{"href":"https:\/\/jaimerios.com\/index.php?rest_route=\/wp\/v2\/posts\/312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jaimerios.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jaimerios.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jaimerios.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jaimerios.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=312"}],"version-history":[{"count":0,"href":"https:\/\/jaimerios.com\/index.php?rest_route=\/wp\/v2\/posts\/312\/revisions"}],"wp:attachment":[{"href":"https:\/\/jaimerios.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jaimerios.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jaimerios.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}