Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
9479e4e2
Commit
9479e4e2
authored
Apr 25, 2013
by
Masaki Muranaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix underlying memory leaks. When realloc is failed, memories are leaked.
parent
8464cac6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
src/load.c
src/load.c
+17
-2
No files found.
src/load.c
View file @
9479e4e2
...
@@ -389,12 +389,19 @@ read_rite_section_lineno_file(mrb_state *mrb, FILE *fp, size_t sirep)
...
@@ -389,12 +389,19 @@ read_rite_section_lineno_file(mrb_state *mrb, FILE *fp, size_t sirep)
//Read Binary Data Section
//Read Binary Data Section
for
(
n
=
0
,
i
=
sirep
;
n
<
nirep
;
n
++
,
i
++
)
{
for
(
n
=
0
,
i
=
sirep
;
n
<
nirep
;
n
++
,
i
++
)
{
void
*
ptr
;
if
(
fread
(
buf
,
record_header_size
,
1
,
fp
)
==
0
)
{
if
(
fread
(
buf
,
record_header_size
,
1
,
fp
)
==
0
)
{
result
=
MRB_DUMP_READ_FAULT
;
result
=
MRB_DUMP_READ_FAULT
;
goto
error_exit
;
goto
error_exit
;
}
}
buf_size
=
bin_to_uint32
(
&
buf
[
0
]);
buf_size
=
bin_to_uint32
(
&
buf
[
0
]);
buf
=
(
uint8_t
*
)
mrb_realloc
(
mrb
,
buf
,
buf_size
);
ptr
=
mrb_realloc
(
mrb
,
buf
,
buf_size
);
if
(
!
ptr
)
{
result
=
MRB_DUMP_GENERAL_FAILURE
;
goto
error_exit
;
}
buf
=
(
uint8_t
*
)
ptr
;
if
(
fread
(
&
buf
[
record_header_size
],
buf_size
-
record_header_size
,
1
,
fp
)
==
0
)
{
if
(
fread
(
&
buf
[
record_header_size
],
buf_size
-
record_header_size
,
1
,
fp
)
==
0
)
{
result
=
MRB_DUMP_READ_FAULT
;
result
=
MRB_DUMP_READ_FAULT
;
...
@@ -439,12 +446,20 @@ read_rite_section_irep_file(mrb_state *mrb, FILE *fp)
...
@@ -439,12 +446,20 @@ read_rite_section_irep_file(mrb_state *mrb, FILE *fp)
//Read Binary Data Section
//Read Binary Data Section
for
(
n
=
0
,
i
=
sirep
;
n
<
nirep
;
n
++
,
i
++
)
{
for
(
n
=
0
,
i
=
sirep
;
n
<
nirep
;
n
++
,
i
++
)
{
void
*
ptr
;
if
(
fread
(
buf
,
record_header_size
,
1
,
fp
)
==
0
)
{
if
(
fread
(
buf
,
record_header_size
,
1
,
fp
)
==
0
)
{
result
=
MRB_DUMP_READ_FAULT
;
result
=
MRB_DUMP_READ_FAULT
;
goto
error_exit
;
goto
error_exit
;
}
}
buf_size
=
bin_to_uint32
(
&
buf
[
0
]);
buf_size
=
bin_to_uint32
(
&
buf
[
0
]);
buf
=
(
uint8_t
*
)
mrb_realloc
(
mrb
,
buf
,
buf_size
);
ptr
=
mrb_realloc
(
mrb
,
buf
,
buf_size
);
if
(
!
ptr
)
{
result
=
MRB_DUMP_GENERAL_FAILURE
;
goto
error_exit
;
}
buf
=
(
uint8_t
*
)
ptr
;
if
(
fread
(
&
buf
[
record_header_size
],
buf_size
-
record_header_size
,
1
,
fp
)
==
0
)
{
if
(
fread
(
&
buf
[
record_header_size
],
buf_size
-
record_header_size
,
1
,
fp
)
==
0
)
{
result
=
MRB_DUMP_READ_FAULT
;
result
=
MRB_DUMP_READ_FAULT
;
goto
error_exit
;
goto
error_exit
;
...
...
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