Getting an assert in cocos2dx 3.15 with sprintf

Why would this assert:

char* buf = new char[1];
sprintf(buf, “%d”, 4);
CC_SAFE_DELETE_ARRAY(buf);

and this not assert?

char* buf = new char[2];
sprintf(buf, “%d”, 4);
CC_SAFE_DELETE_ARRAY(buf);

This is happening in windows 7 64bit

I tried in ios and android and no assert.

It says heap corruption detected. CRT detected that the application wrote to memory after end of heap buffer.

try

char ch[32];
sprintf(ch,"%d",4);