Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
30dfc1da
Commit
30dfc1da
authored
9 years ago
by
Vittorio Giovara
Browse files
Options
Downloads
Patches
Plain Diff
cws2fws: Close file handles on error
Reported-By: infer
parent
a9b2a511
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/cws2fws.c
+12
-9
12 additions, 9 deletions
tools/cws2fws.c
with
12 additions
and
9 deletions
tools/cws2fws.c
+
12
−
9
View file @
30dfc1da
...
@@ -31,6 +31,7 @@ int main(int argc, char *argv[])
...
@@ -31,6 +31,7 @@ int main(int argc, char *argv[])
char
buf_in
[
1024
],
buf_out
[
65536
];
char
buf_in
[
1024
],
buf_out
[
65536
];
z_stream
zstream
;
z_stream
zstream
;
struct
stat
statbuf
;
struct
stat
statbuf
;
int
ret
=
1
;
if
(
argc
<
3
)
{
if
(
argc
<
3
)
{
printf
(
"Usage: %s <infile.swf> <outfile.swf>
\n
"
,
argv
[
0
]);
printf
(
"Usage: %s <infile.swf> <outfile.swf>
\n
"
,
argv
[
0
]);
...
@@ -52,14 +53,12 @@ int main(int argc, char *argv[])
...
@@ -52,14 +53,12 @@ int main(int argc, char *argv[])
if
(
read
(
fd_in
,
&
buf_in
,
8
)
!=
8
)
{
if
(
read
(
fd_in
,
&
buf_in
,
8
)
!=
8
)
{
printf
(
"Header error
\n
"
);
printf
(
"Header error
\n
"
);
close
(
fd_in
);
goto
out
;
close
(
fd_out
);
return
1
;
}
}
if
(
buf_in
[
0
]
!=
'C'
||
buf_in
[
1
]
!=
'W'
||
buf_in
[
2
]
!=
'S'
)
{
if
(
buf_in
[
0
]
!=
'C'
||
buf_in
[
1
]
!=
'W'
||
buf_in
[
2
]
!=
'S'
)
{
printf
(
"Not a compressed flash file
\n
"
);
printf
(
"Not a compressed flash file
\n
"
);
return
1
;
goto
out
;
}
}
fstat
(
fd_in
,
&
statbuf
);
fstat
(
fd_in
,
&
statbuf
);
...
@@ -73,7 +72,7 @@ int main(int argc, char *argv[])
...
@@ -73,7 +72,7 @@ int main(int argc, char *argv[])
buf_in
[
0
]
=
'F'
;
buf_in
[
0
]
=
'F'
;
if
(
write
(
fd_out
,
&
buf_in
,
8
)
<
8
)
{
if
(
write
(
fd_out
,
&
buf_in
,
8
)
<
8
)
{
perror
(
"Error writing output file"
);
perror
(
"Error writing output file"
);
return
1
;
goto
out
;
}
}
zstream
.
zalloc
=
NULL
;
zstream
.
zalloc
=
NULL
;
...
@@ -97,7 +96,7 @@ int main(int argc, char *argv[])
...
@@ -97,7 +96,7 @@ int main(int argc, char *argv[])
if
(
ret
!=
Z_STREAM_END
&&
ret
!=
Z_OK
)
{
if
(
ret
!=
Z_STREAM_END
&&
ret
!=
Z_OK
)
{
printf
(
"Error while decompressing: %d
\n
"
,
ret
);
printf
(
"Error while decompressing: %d
\n
"
,
ret
);
inflateEnd
(
&
zstream
);
inflateEnd
(
&
zstream
);
return
1
;
goto
out
;
}
}
dbgprintf
(
"a_in: %d t_in: %lu a_out: %d t_out: %lu -- %lu out
\n
"
,
dbgprintf
(
"a_in: %d t_in: %lu a_out: %d t_out: %lu -- %lu out
\n
"
,
...
@@ -107,7 +106,8 @@ int main(int argc, char *argv[])
...
@@ -107,7 +106,8 @@ int main(int argc, char *argv[])
if
(
write
(
fd_out
,
&
buf_out
,
zstream
.
total_out
-
last_out
)
<
if
(
write
(
fd_out
,
&
buf_out
,
zstream
.
total_out
-
last_out
)
<
zstream
.
total_out
-
last_out
)
{
zstream
.
total_out
-
last_out
)
{
perror
(
"Error writing output file"
);
perror
(
"Error writing output file"
);
return
1
;
inflateEnd
(
&
zstream
);
goto
out
;
}
}
i
+=
len
;
i
+=
len
;
...
@@ -128,12 +128,15 @@ int main(int argc, char *argv[])
...
@@ -128,12 +128,15 @@ int main(int argc, char *argv[])
lseek
(
fd_out
,
4
,
SEEK_SET
);
lseek
(
fd_out
,
4
,
SEEK_SET
);
if
(
write
(
fd_out
,
&
buf_in
,
4
)
<
4
)
{
if
(
write
(
fd_out
,
&
buf_in
,
4
)
<
4
)
{
perror
(
"Error writing output file"
);
perror
(
"Error writing output file"
);
return
1
;
inflateEnd
(
&
zstream
);
goto
out
;
}
}
}
}
ret
=
0
;
inflateEnd
(
&
zstream
);
inflateEnd
(
&
zstream
);
out:
close
(
fd_in
);
close
(
fd_in
);
close
(
fd_out
);
close
(
fd_out
);
return
0
;
return
ret
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment