[PATCH] xrandr: calloc XRRModeInfo's passed to libXrandr.
Andy Ritger
aritger at nvidia.com
Thu May 2 01:20:27 PDT 2013
The "--newmode" commandline option initializes an XRRModeInfo and passes
it into XRRCreateMode(). calloc(3) it to avoid uninitialized fields.
For consistency, calloc(3) all the places where umode_t's (the wrapper
structure for XRRModeInfo) are allocated.
Signed-off-by: Andy Ritger <aritger at nvidia.com>
Tested-by: Nikhil Mahale <nmahale at nvidia.com>
---
xrandr.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/xrandr.c b/xrandr.c
index 305308c..94e5c2e 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -2924,7 +2924,7 @@ main (int argc, char **argv)
}
if (!strcmp ("--newmode", argv[i]))
{
- umode_t *m = malloc (sizeof (umode_t));
+ umode_t *m = calloc (1, sizeof (umode_t));
double clock;
++i;
@@ -2966,7 +2966,7 @@ main (int argc, char **argv)
}
if (!strcmp ("--rmmode", argv[i]))
{
- umode_t *m = malloc (sizeof (umode_t));
+ umode_t *m = calloc (1, sizeof (umode_t));
if (++i >= argc) argerr ("%s requires an argument\n", argv[i-1]);
set_name (&m->name, argv[i], name_string|name_xid);
@@ -2979,7 +2979,7 @@ main (int argc, char **argv)
}
if (!strcmp ("--addmode", argv[i]))
{
- umode_t *m = malloc (sizeof (umode_t));
+ umode_t *m = calloc (1, sizeof (umode_t));
if (i+2 >= argc) argerr ("%s requires two arguments\n", argv[i]);
set_name (&m->output, argv[++i], name_string|name_xid);
@@ -2993,7 +2993,7 @@ main (int argc, char **argv)
}
if (!strcmp ("--delmode", argv[i]))
{
- umode_t *m = malloc (sizeof (umode_t));
+ umode_t *m = calloc (1, sizeof (umode_t));
if (i+2 >= argc) argerr ("%s requires two arguments\n", argv[i]);
set_name (&m->output, argv[++i], name_string|name_xid);
--
1.7.2.5
More information about the xorg-devel
mailing list