Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
213e63ee
Commit
213e63ee
authored
Jun 20, 2019
by
Ulrich Sibiller
Committed by
Mike Gabriel
Jun 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Screen.c: fix two memleaks
While at it create and use the freeDepths() helper function.
parent
e63d9de4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
19 deletions
+18
-19
Screen.c
nx-X11/programs/Xserver/hw/nxagent/Screen.c
+18
-19
No files found.
nx-X11/programs/Xserver/hw/nxagent/Screen.c
View file @
213e63ee
...
...
@@ -844,6 +844,19 @@ static int nxagentColorOffset(unsigned long mask)
return
count
;
}
void
freeDepths
(
DepthPtr
depths
,
int
num
)
{
for
(
int
i
=
0
;
i
<
num
;
i
++
)
{
#ifdef DEBUG
fprintf
(
stderr
,
"%s: freeing depth [%d] index [%d] vids [%p]
\n
"
,
__func__
,
depths
[
i
].
depth
,
i
,
(
void
*
)
depths
[
i
].
vids
);
#endif
free
(
depths
[
i
].
vids
);
depths
[
i
].
vids
=
NULL
;
}
free
(
depths
);
}
Bool
nxagentOpenScreen
(
ScreenPtr
pScreen
,
int
argc
,
char
*
argv
[])
{
...
...
@@ -1335,6 +1348,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
if
(
!
pFrameBufferBits
)
{
freeDepths
(
depths
,
numDepths
);
return
FALSE
;
}
...
...
@@ -1356,6 +1370,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
if
(
!
fbScreenInit
(
pScreen
,
pFrameBufferBits
,
nxagentOption
(
RootWidth
),
nxagentOption
(
RootHeight
),
monitorResolution
,
monitorResolution
,
PixmapBytePad
(
nxagentOption
(
RootWidth
),
rootDepth
),
bitsPerPixel
))
{
freeDepths
(
depths
,
numDepths
);
return
FALSE
;
}
...
...
@@ -1391,15 +1406,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
* by fbScreenInit with our own.
*/
for
(
int
i
=
0
;
i
<
pScreen
->
numDepths
;
i
++
)
{
#ifdef DEBUG
fprintf
(
stderr
,
"%s: freeing depth [%d] index [%d] vids [%p]
\n
"
,
__func__
,
pScreen
->
allowedDepths
[
i
].
depth
,
i
,
(
void
*
)
pScreen
->
allowedDepths
[
i
].
vids
);
#endif
free
(
pScreen
->
allowedDepths
[
i
].
vids
);
}
free
(
pScreen
->
allowedDepths
);
freeDepths
(
pScreen
->
allowedDepths
,
pScreen
->
numDepths
);
pScreen
->
allowedDepths
=
depths
;
pScreen
->
numDepths
=
numDepths
;
pScreen
->
rootDepth
=
rootDepth
;
...
...
@@ -2155,15 +2162,8 @@ Bool nxagentCloseScreen(ScreenPtr pScreen)
* them again.
*/
for
(
int
i
=
0
;
i
<
pScreen
->
numDepths
;
i
++
)
{
#ifdef DEBUG
fprintf
(
stderr
,
"%s: freeing depth [%d] index [%d] vids [%p]
\n
"
,
__func__
,
pScreen
->
allowedDepths
[
i
].
depth
,
i
,
(
void
*
)
pScreen
->
allowedDepths
[
i
].
vids
);
#endif
free
(
pScreen
->
allowedDepths
[
i
].
vids
);
pScreen
->
allowedDepths
[
i
].
vids
=
NULL
;
}
freeDepths
(
pScreen
->
allowedDepths
,
pScreen
->
numDepths
);
pScreen
->
allowedDepths
=
NULL
;
pScreen
->
numDepths
=
0
;
/*
...
...
@@ -2172,7 +2172,6 @@ Bool nxagentCloseScreen(ScreenPtr pScreen)
free
(((
PixmapPtr
)
pScreen
->
devPrivate
)
->
devPrivate
.
ptr
);
free
(
pScreen
->
devPrivate
);
pScreen
->
devPrivate
=
NULL
;
free
(
pScreen
->
allowedDepths
);
pScreen
->
allowedDepths
=
NULL
;
free
(
pScreen
->
visuals
);
pScreen
->
visuals
=
NULL
;
fbCloseScreen
(
pScreen
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment