Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
2e1f56d9
Commit
2e1f56d9
authored
Feb 28, 2018
by
Sebastian Martin Dicke
Committed by
Hisham Muhammad
Mar 16, 2018
Browse files
Changed type of some integer variables to avoid overflows
parent
6ee99566
Changes
1
Hide whitespace changes
Inline
Side-by-side
StringUtils.c
View file @
2e1f56d9
...
...
@@ -27,11 +27,11 @@ in the source distribution for its full text.
*/
char
*
String_cat
(
const
char
*
s1
,
const
char
*
s2
)
{
in
t
l1
=
strlen
(
s1
);
in
t
l2
=
strlen
(
s2
);
size_
t
l1
=
strlen
(
s1
);
size_
t
l2
=
strlen
(
s2
);
char
*
out
=
xMalloc
(
l1
+
l2
+
1
);
strncpy
(
out
,
s1
,
l1
);
strncpy
(
out
+
l1
,
s2
,
l2
+
1
);
strncpy
(
out
+
l1
,
s2
,
l2
+
1
);
return
out
;
}
...
...
@@ -39,7 +39,7 @@ char* String_trim(const char* in) {
while
(
in
[
0
]
==
' '
||
in
[
0
]
==
'\t'
||
in
[
0
]
==
'\n'
)
{
in
++
;
}
in
t
len
=
strlen
(
in
);
size_
t
len
=
strlen
(
in
);
while
(
len
>
0
&&
(
in
[
len
-
1
]
==
' '
||
in
[
len
-
1
]
==
'\t'
||
in
[
len
-
1
]
==
'\n'
))
{
len
--
;
}
...
...
@@ -80,7 +80,7 @@ char** String_split(const char* s, char sep, int* n) {
s
+=
size
+
1
;
}
if
(
s
[
0
]
!=
'\0'
)
{
in
t
size
=
strlen
(
s
);
size_
t
size
=
strlen
(
s
);
char
*
token
=
xMalloc
(
size
+
1
);
strncpy
(
token
,
s
,
size
+
1
);
out
[
ctr
]
=
token
;
...
...
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