mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
doc/examples/hw_decode: check fopen return value for output file
The output file fopen() result is not checked. If it fails (e.g. permission denied or invalid path), output_file is NULL and the subsequent fwrite() call will crash. Add a NULL check with an error message, consistent with the existing error handling pattern in this example. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
This commit is contained in:
@@ -233,6 +233,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* open the file to dump raw data */
|
||||
output_file = fopen(argv[3], "w+b");
|
||||
if (!output_file) {
|
||||
fprintf(stderr, "Cannot open output file '%s'\n", argv[3]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* actual decoding and dump the raw data */
|
||||
while (ret >= 0) {
|
||||
|
||||
Reference in New Issue
Block a user