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
52d39e62
Commit
52d39e62
authored
Oct 23, 2012
by
Yukihiro Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent resource leak (outfile)
parent
f5b6f03c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
23 deletions
+28
-23
tools/mrbc/mrbc.c
tools/mrbc/mrbc.c
+28
-23
No files found.
tools/mrbc/mrbc.c
View file @
52d39e62
...
@@ -70,6 +70,7 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
...
@@ -70,6 +70,7 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
char
*
infile
=
NULL
;
char
*
infile
=
NULL
;
char
*
outfile
=
NULL
;
char
*
outfile
=
NULL
;
char
**
origargv
=
argv
;
char
**
origargv
=
argv
;
int
result
=
0
;
static
const
struct
_args
args_zero
=
{
0
};
static
const
struct
_args
args_zero
=
{
0
};
*
args
=
args_zero
;
*
args
=
args_zero
;
...
@@ -93,7 +94,8 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
...
@@ -93,7 +94,8 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
args
->
initname
=
(
*
argv
)
+
2
;
args
->
initname
=
(
*
argv
)
+
2
;
if
(
*
args
->
initname
==
'\0'
)
{
if
(
*
args
->
initname
==
'\0'
)
{
printf
(
"%s: Function name is not specified.
\n
"
,
*
origargv
);
printf
(
"%s: Function name is not specified.
\n
"
,
*
origargv
);
return
-
2
;
result
=
-
2
;
goto
exit
;
}
}
args
->
dump_type
=
((
*
argv
)[
1
]
==
'B'
)
?
DUMP_TYPE_BIN
:
DUMP_TYPE_CODE
;
args
->
dump_type
=
((
*
argv
)[
1
]
==
'B'
)
?
DUMP_TYPE_BIN
:
DUMP_TYPE_CODE
;
break
;
break
;
...
@@ -117,8 +119,8 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
...
@@ -117,8 +119,8 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
mrb_show_copyright
(
mrb
);
mrb_show_copyright
(
mrb
);
exit
(
0
);
exit
(
0
);
}
}
else
return
-
3
;
result
=
-
3
;
return
0
;
goto
exit
;
default:
default:
break
;
break
;
}
}
...
@@ -127,33 +129,36 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
...
@@ -127,33 +129,36 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
args
->
filename
=
infile
=
*
argv
;
args
->
filename
=
infile
=
*
argv
;
if
((
args
->
rfp
=
fopen
(
infile
,
"r"
))
==
NULL
)
{
if
((
args
->
rfp
=
fopen
(
infile
,
"r"
))
==
NULL
)
{
printf
(
"%s: Cannot open program file. (%s)
\n
"
,
*
origargv
,
infile
);
printf
(
"%s: Cannot open program file. (%s)
\n
"
,
*
origargv
,
infile
);
return
0
;
goto
exit
;
}
}
}
}
}
}
if
(
infile
==
NULL
)
if
(
infile
==
NULL
)
{
return
-
4
;
result
=
-
4
;
if
(
args
->
check_syntax
)
goto
exit
;
return
0
;
}
if
(
!
args
->
check_syntax
)
{
if
(
outfile
==
NULL
)
{
if
(
outfile
==
NULL
)
{
if
(
strcmp
(
"-"
,
infile
)
==
0
)
{
if
(
strcmp
(
"-"
,
infile
)
==
0
)
{
outfile
=
infile
;
outfile
=
infile
;
}
else
{
outfile
=
get_outfilename
(
infile
,
args
->
ext
);
}
}
}
else
{
if
(
strcmp
(
"-"
,
outfile
)
==
0
)
{
outfile
=
get_outfilename
(
infile
,
args
->
ext
);
args
->
wfp
=
stdout
;
}
else
if
((
args
->
wfp
=
fopen
(
outfile
,
"wb"
))
==
NULL
)
{
printf
(
"%s: Cannot open output file. (%s)
\n
"
,
*
origargv
,
outfile
);
result
=
-
1
;
goto
exit
;
}
}
}
}
if
(
strcmp
(
"-"
,
outfile
)
==
0
)
{
exit:
args
->
wfp
=
stdout
;
if
(
outfile
&&
infile
!=
outfile
)
free
(
outfile
);
}
return
result
;
else
if
((
args
->
wfp
=
fopen
(
outfile
,
"wb"
))
==
NULL
)
{
printf
(
"%s: Cannot open output file. (%s)
\n
"
,
*
origargv
,
outfile
);
return
0
;
}
return
0
;
}
}
static
void
static
void
...
...
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