xfree86: utils: gracefully handle allocation failure.
Better failing gracefully instead of hard crash via segfault. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
6c9f2ecc32
commit
111ca8af21
|
@ -294,7 +294,9 @@ vert_refresh(int h_pixels, int v_lines, float freq, int interlaced, int margins)
|
||||||
float h_front_porch;
|
float h_front_porch;
|
||||||
float v_odd_front_porch_lines;
|
float v_odd_front_porch_lines;
|
||||||
|
|
||||||
mode *m = (mode *) malloc(sizeof(mode));
|
mode *m = (mode *) calloc(1, sizeof(mode));
|
||||||
|
if (!m)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
/* 1. In order to give correct results, the number of horizontal
|
/* 1. In order to give correct results, the number of horizontal
|
||||||
* pixels requested is first processed to ensure that it is divisible
|
* pixels requested is first processed to ensure that it is divisible
|
||||||
|
@ -604,6 +606,8 @@ parse_command_line(int argc, char *argv[])
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
options *o = (options *) calloc(1, sizeof(options));
|
options *o = (options *) calloc(1, sizeof(options));
|
||||||
|
if (!o)
|
||||||
|
goto bad_option;
|
||||||
|
|
||||||
if (argc < 4)
|
if (argc < 4)
|
||||||
goto bad_option;
|
goto bad_option;
|
||||||
|
|
Loading…
Reference in New Issue