Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
esp
mongoose
Commits
e34747d1
Commit
e34747d1
authored
Oct 29, 2015
by
Deomid Ryabkov
Committed by
Marko Mikulicic
Oct 30, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle case of malloc failure in mbuf_resize
PUBLISHED_FROM=0cb98ac520b8aeb8bbeb2f23b8c65c62ab256021
parent
1a6bc7c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
mongoose.c
mongoose.c
+7
-5
No files found.
mongoose.c
View file @
e34747d1
...
@@ -144,13 +144,15 @@ void mbuf_free(struct mbuf *mbuf) {
...
@@ -144,13 +144,15 @@ void mbuf_free(struct mbuf *mbuf) {
void
mbuf_resize
(
struct
mbuf
*
a
,
size_t
new_size
)
{
void
mbuf_resize
(
struct
mbuf
*
a
,
size_t
new_size
)
{
if
(
new_size
>
a
->
size
||
(
new_size
<
a
->
size
&&
new_size
>=
a
->
len
))
{
if
(
new_size
>
a
->
size
||
(
new_size
<
a
->
size
&&
new_size
>=
a
->
len
))
{
a
->
buf
=
(
char
*
)
MBUF_REALLOC
(
a
->
buf
,
new_size
);
char
*
buf
=
(
char
*
)
MBUF_REALLOC
(
a
->
buf
,
new_size
);
/*
/*
* In case realloc fails, there's not much we can do
except set size to 0.
* In case realloc fails, there's not much we can do
, except keep things as
*
Note that NULL is a valid return value from realloc when size == 0, but
*
they are. Note that NULL is a valid return value from realloc when
* that is covered too.
*
size == 0, but
that is covered too.
*/
*/
a
->
size
=
(
a
->
buf
!=
NULL
?
new_size
:
0
);
if
(
buf
==
NULL
&&
new_size
!=
0
)
return
;
a
->
buf
=
buf
;
a
->
size
=
new_size
;
}
}
}
}
...
...
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