Created
December 7, 2016 02:23
-
-
Save MadCoder/0a6f87938b17f197f682e837a53722a8 to your computer and use it in GitHub Desktop.
Horrible C Scope abuse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
void | |
invalid_code(void) | |
{ | |
void (^block)(void); | |
if (rand() % 2) { | |
block = ^{ printf("odd\n"); }; | |
} else { | |
block = ^{ printf("even\n"); }; | |
} | |
block(); | |
} | |
void | |
valid_code(void) | |
{ | |
void (^block)(void); | |
if (rand() % 2) | |
block = ^{ printf("odd\n"); }; | |
else | |
block = ^{ printf("even\n"); }; | |
block(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment