xfree86: avoid memory leak on realloc failure
Found by Oracle Parfait 13.3 static analyzer:
Memory leak [memory-leak]:
Memory leak of pointer optname allocated with asprintf(&optname,
"\"%s\"", p->name)
at line 326 of hw/xfree86/common/xf86Configure.c in function
'configureDeviceSection'.
optname allocated at line 309 with asprintf(&optname, "\"%s\"",
p->name)
Fixes: code inherited from XFree86
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1730>
This commit is contained in:
parent
0aaee8e7bc
commit
84b57b8d32
|
|
@ -314,8 +314,10 @@ configureDeviceSection(int screennum)
|
|||
len += strlen(opttype);
|
||||
|
||||
ptr->dev_comment = realloc(ptr->dev_comment, len);
|
||||
if (!ptr->dev_comment)
|
||||
if (!ptr->dev_comment) {
|
||||
free(optname);
|
||||
break;
|
||||
}
|
||||
p_e = ptr->dev_comment + strlen(ptr->dev_comment);
|
||||
sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle,
|
||||
opttype, suffix);
|
||||
|
|
|
|||
Loading…
Reference in New Issue