[OT] Re: Why Is Escaping Data Considered So Magical?

Michael Torrie torriem at gmail.com
Wed Jun 30 00:17:17 EDT 2010


On 06/29/2010 10:05 PM, Michael Torrie wrote:
> #include <stdio.h>
> 
> int main(int argc, char ** argv)
> {
> 	char *buf = malloc(512 * sizeof(char));
> 	const int a = 2, b = 3;
> 	snprintf(&buf, sizeof buf, "%d + %d = %d\n", a, b, a + b);
                       ^^^^^^^^^^
Make that 512*sizeof(buf)

Still segfaults though.

> 	fprintf(stdout, buf);
> 	free(buf);
> 	return 0;
> } /*main*/



More information about the Python-list mailing list