...
Code Block | ||
---|---|---|
| ||
volatile sig_atomic_t denom; void sighandle(int s){ /* Fix the offending volatile */ if (denom == 0) { denom == 1; } /* Everything is ok */ return; } int main(int argc, char *argv[]){ int result = 0; Â if (argc < 2) { Â Â Â return 0; } Â int result = 0; Â Â denom = (int)strtol(argv[1], (char **)NULL, 10); Â signal(SIGFPE,(*sighandle)); Â result = 100/denom; Â return 0; } |
...
Code Block | ||
---|---|---|
| ||
volatile sig_atomic_t denom; void sighandle(int s){ /* No recovery */ abort(); } int main(int argc, char *argv[]){ int result = 0; if (argc < 2) { return 0; } int result = 0; denom = (int)strtol(argv[1], (char **)NULL, 10); signal(SIGFPE,(*sighandle)); result = 100/denom; return 0; } |
...