[PATCH 01/11] xf86ValidateModes: xnfalloc(strlen) + strcpy => xnfstrdup

Alan Coopersmith alan.coopersmith at oracle.com
Mon Nov 29 20:57:38 PST 2010


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 hw/xfree86/common/xf86Mode.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c
index d03310e..4d64bd4 100644
--- a/hw/xfree86/common/xf86Mode.c
+++ b/hw/xfree86/common/xf86Mode.c
@@ -1632,8 +1632,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
 	    new = xnfcalloc(1, sizeof(DisplayModeRec));
 	    new->prev = last;
 	    new->type = M_T_USERDEF;
-	    new->name = xnfalloc(strlen(modeNames[i]) + 1);
-	    strcpy(new->name, modeNames[i]);
+	    new->name = xnfstrdup(modeNames[i]);
 	    if (new->prev)
 		new->prev->next = new;
 	    *endp = last = new;
@@ -1705,10 +1704,9 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
 
 	    p = xnfcalloc(1, sizeof(DisplayModeRec));
 	    p->prev = last;
-	    p->name = xnfalloc(strlen(r->name) + 1);
+	    p->name = xnfstrdup(r->name);
 	    if (!userModes)
 		p->type = M_T_USERDEF;
-	    strcpy(p->name, r->name);
 	    if (p->prev)
 		p->prev->next = p;
 	    *endp = last = p;
-- 
1.7.3.2



More information about the xorg-devel mailing list