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
58b3c8cd
You need to sign in or sign up before continuing.
Commit
58b3c8cd
authored
Apr 09, 2020
by
Ulrich Sibiller
Committed by
Mike Gabriel
May 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Font.c: fix realloc bugs
parent
acd45283
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
20 deletions
+23
-20
Font.c
nx-X11/programs/Xserver/hw/nxagent/Font.c
+23
-20
No files found.
nx-X11/programs/Xserver/hw/nxagent/Font.c
View file @
58b3c8cd
...
...
@@ -192,7 +192,6 @@ void nxagentFreeFontCache(void)
}
SAFE_free
(
CACHE_ENTRY_PTR
);
CACHE_ENTRY_PTR
=
NULL
;
CACHE_INDEX
=
0
;
CACHE_SIZE
=
0
;
...
...
@@ -289,16 +288,16 @@ void nxagentListRemoteAddName(const char *name, int status)
if
(
nxagentRemoteFontList
.
length
==
nxagentRemoteFontList
.
listSize
)
{
/* FIXME: if realloc fails the pointer is lost! */
nxagentRemoteFontList
.
list
=
realloc
(
nxagentRemoteFontList
.
list
,
sizeof
(
nxagentFontRecPtr
)
*
(
nxagentRemoteFontList
.
listSize
+
1000
));
int
num
=
nxagentRemoteFontList
.
listSize
+
1000
;
nxagentFontRecPtr
*
tmp1
=
realloc
(
nxagentRemoteFontList
.
list
,
sizeof
(
nxagentFontRecPtr
)
*
num
);
if
(
nxagentRemoteFontList
.
list
==
NULL
)
if
(
tmp1
==
NULL
)
{
FatalError
(
"Font: remote list memory re-allocation failed!.
\n
"
);
}
nxagentRemoteFontList
.
listSize
+=
1000
;
nxagentRemoteFontList
.
list
=
tmp1
;
nxagentRemoteFontList
.
listSize
=
num
;
}
if
(
pos
<
nxagentRemoteFontList
.
length
)
...
...
@@ -542,15 +541,18 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont)
if
(
CACHE_INDEX
==
CACHE_SIZE
)
{
/* FIXME: if realloc fails the pointer is lost */
CACHE_ENTRY_PTR
=
realloc
(
CACHE_ENTRY_PTR
,
sizeof
(
nxCacheFontEntryRecPtr
)
*
(
CACHE_SIZE
+
100
));
int
num
=
CACHE_SIZE
+
100
;
if
(
CACHE_ENTRY_PTR
==
NULL
)
nxCacheFontEntryRecPtr
*
tmp1
=
realloc
(
CACHE_ENTRY_PTR
,
sizeof
(
nxCacheFontEntryRecPtr
)
*
num
);
if
(
tmp1
==
NULL
)
{
FatalError
(
"Font: Cache list memory re-allocation failed.
\n
"
);
}
CACHE_SIZE
+=
100
;
CACHE_ENTRY_PTR
=
tmp1
;
CACHE_SIZE
=
num
;
}
CACHE_ENTRY
(
CACHE_INDEX
)
=
malloc
(
sizeof
(
nxCacheFontEntryRec
));
...
...
@@ -888,22 +890,23 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id)
}
else
if
(
nxagentFailedToReconnectFonts
.
index
==
nxagentFailedToReconnectFonts
.
size
-
1
)
{
nxagentFailedToReconnectFonts
.
size
*=
2
;
/* FIXME: if realloc fails the pointer is lost */
nxagentFailedToReconnectFonts
.
font
=
realloc
(
nxagentFailedToReconnectFonts
.
font
,
nxagentFailedToReconnectFonts
.
size
*
sizeof
(
FontPtr
));
int
num
=
2
*
nxagentFailedToReconnectFonts
.
size
;
nxagentFailedToReconnectFonts
.
id
=
realloc
(
nxagentFailedToReconnectFonts
.
id
,
nxagentFailedToReconnectFonts
.
size
*
sizeof
(
XID
));
FontPtr
*
tmp1
=
realloc
(
nxagentFailedToReconnectFonts
.
font
,
num
*
sizeof
(
FontPtr
));
XID
*
tmp2
=
realloc
(
nxagentFailedToReconnectFonts
.
id
,
num
*
sizeof
(
XID
));
if
(
nxagentFailedToReconnectFonts
.
font
==
NULL
||
nxagentFailedToReconnectFonts
.
id
==
NULL
)
if
(
tmp1
==
NULL
||
tmp2
==
NULL
)
{
SAFE_free
(
tmp1
);
SAFE_free
(
tmp2
);
FatalError
(
"Font: font not reconnected memory re-allocation failed!.
\n
"
);
}
nxagentFailedToReconnectFonts
.
size
=
num
;
nxagentFailedToReconnectFonts
.
font
=
tmp1
;
nxagentFailedToReconnectFonts
.
id
=
tmp2
;
#ifdef NXAGENT_RECONNECT_FONT_DEBUG
fprintf
(
stderr
,
"nxagentCollectFailedFont: reallocated memory.
\n
"
);
#endif
...
...
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