Skip to content

Instantly share code, notes, and snippets.

@jld
Created January 15, 2018 22:43
Show Gist options
  • Save jld/1d447be7ab180cfa74765fedb42ba164 to your computer and use it in GitHub Desktop.
Save jld/1d447be7ab180cfa74765fedb42ba164 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LARGENUM 0x80000001
int main()
{
char* buf = malloc(LARGENUM + 1);
memset(buf, 'X', LARGENUM);
buf[LARGENUM] = '\0';
printf("%s", buf);
return 0;
}
@rabauke
Copy link

rabauke commented Jan 16, 2018

This program is ill-formed. It is not allowed to print more characters than INT_MAX in a single printf function call. See the description of the meaning of the printf return value as defined in the C language standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment