mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 11:24:05 +00:00
fixed potential out of bounds iteration
This commit is contained in:
parent
7e2bbcfb64
commit
4d87fb2397
|
@ -21,7 +21,6 @@
|
|||
#include "cfg.h"
|
||||
#include "gop.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1366,12 +1365,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
|
|||
}
|
||||
else if OPT("input-file-format") {
|
||||
int8_t file_format = 0;
|
||||
char value_lower_case[255];
|
||||
for (int i = 0; i < 255; i++) {
|
||||
value_lower_case[i] = tolower(value[i]);
|
||||
}
|
||||
fprintf(stderr, "value: %s ", value_lower_case);
|
||||
if (!parse_enum(value_lower_case, file_format_names, &file_format)) {
|
||||
if (!parse_enum(value, file_format_names, &file_format)) {
|
||||
fprintf(stderr, "Invalid input file format %s. Valid values include %s, %s, and %s\n", value,
|
||||
file_format_names[0],
|
||||
file_format_names[1],
|
||||
|
@ -1379,7 +1373,6 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
|
|||
return 0;
|
||||
}
|
||||
cfg->file_format = file_format;
|
||||
fprintf(stderr, "%i\n", cfg->file_format);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
|
|
|
@ -198,14 +198,15 @@ static int detect_file_format(const char *file_name) {
|
|||
// If delim is not found, return 0
|
||||
char* sub_str = (char*)strrchr(file_name, '.');
|
||||
if (!sub_str) return 0;
|
||||
if (strlen(sub_str) != 4) return 0;
|
||||
char ending_lower_case[4];
|
||||
for(int i = 0; i < 4; i++){
|
||||
ending_lower_case[i] = tolower(sub_str[i]);
|
||||
}
|
||||
|
||||
// KVZ_FILE_FORMAT
|
||||
if (strcmp(ending_lower_case, ".y4m") == 0) return 1;
|
||||
else if (strcmp(ending_lower_case, ".yuv") == 0) return 2;
|
||||
if (strncmp(ending_lower_case, ".y4m", 4) == 0) return 1;
|
||||
else if (strncmp(ending_lower_case, ".yuv", 4) == 0) return 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue