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
dc61b6cc
Commit
dc61b6cc
authored
Jan 03, 2018
by
Ulrich Sibiller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Args.c: use strdup instead of malloc
parent
96e43006
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
34 deletions
+6
-34
Args.c
nx-X11/programs/Xserver/hw/nxagent/Args.c
+6
-34
No files found.
nx-X11/programs/Xserver/hw/nxagent/Args.c
View file @
dc61b6cc
...
...
@@ -215,14 +215,10 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
if
((
!
strcmp
(
argv
[
j
],
"-display"
))
&&
(
j
+
1
<
argc
))
{
envOptions
=
malloc
(
strlen
(
argv
[
j
+
1
])
+
1
);
envOptions
=
strdup
(
argv
[
j
+
1
]
);
if
(
envOptions
!=
NULL
)
{
envOptions
=
strcpy
(
envOptions
,
argv
[
j
+
1
]);
}
#ifdef WARNING
else
if
(
envOptions
==
NULL
)
{
fprintf
(
stderr
,
"ddxProcessArgument: WARNING! failed string allocation.
\n
"
);
}
...
...
@@ -234,14 +230,10 @@ int ddxProcessArgument(int argc, char *argv[], int i)
if
((
envOptions
==
NULL
)
&&
(
envDisplay
!=
NULL
))
{
envOptions
=
malloc
(
strlen
(
envDisplay
)
+
1
);
envOptions
=
strdup
(
envDisplay
);
if
(
envOptions
!=
NULL
)
{
envOptions
=
strcpy
(
envOptions
,
envDisplay
);
}
#ifdef WARNING
else
if
(
envOptions
==
NULL
)
{
fprintf
(
stderr
,
"ddxProcessArgument: WARNING! failed string allocation.
\n
"
);
}
...
...
@@ -696,35 +688,15 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
if
(
++
i
<
argc
)
{
int
size
;
free
(
nxagentKeyboard
);
nxagentKeyboard
=
NULL
;
if
((
size
=
strlen
(
argv
[
i
]))
<
256
)
{
if
((
nxagentKeyboard
=
malloc
(
size
+
1
))
==
NULL
)
nxagentKeyboard
=
strdup
(
argv
[
i
]);
if
(
nxagentKeyboard
==
NULL
)
{
FatalError
(
"malloc failed"
);
}
strncpy
(
nxagentKeyboard
,
argv
[
i
],
size
);
nxagentKeyboard
[
size
]
=
'\0'
;
}
#ifdef WARNING
else
{
/*
* it is useless to remember a kbtype
* option that has just been truncated.
*/
fprintf
(
stderr
,
"ddxProcessArgument: WARNING! Option [%s] too long. "
"It will be ignored.
\n
"
,
argv
[
i
]);
}
#endif
return
2
;
}
...
...
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