mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-30 02:12:30 +01:00
WINGs: to not allocate memory for a short lived array (Coverity #50136)
As pointed by Coverity, the array created to temporary store the list of Atoms used in the function 'requestHandler' was leaked. Because this array is very short lived, there is no need to allocate memory for this, it just participates in memory fragmentation. Instead, we use now memory on the stack which is more efficient. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
b80118fb41
commit
c5d4c27a90
@@ -2061,15 +2061,14 @@ static WMData *requestHandler(WMView * view, Atom selection, Atom target, void *
|
||||
|
||||
_TARGETS = XInternAtom(dpy, "TARGETS", False);
|
||||
if (target == _TARGETS) {
|
||||
Atom *ptr;
|
||||
Atom array[4];
|
||||
|
||||
ptr = wmalloc(4 * sizeof(Atom));
|
||||
ptr[0] = _TARGETS;
|
||||
ptr[1] = XA_STRING;
|
||||
ptr[2] = TEXT;
|
||||
ptr[3] = COMPOUND_TEXT;
|
||||
array[0] = _TARGETS;
|
||||
array[1] = XA_STRING;
|
||||
array[2] = TEXT;
|
||||
array[3] = COMPOUND_TEXT;
|
||||
|
||||
data = WMCreateDataWithBytes(ptr, 4 * 4);
|
||||
data = WMCreateDataWithBytes(&array, sizeof(array));
|
||||
WMSetDataFormat(data, 32);
|
||||
|
||||
*type = target;
|
||||
|
||||
Reference in New Issue
Block a user