mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-23 19:24:46 +00:00
Prevent 'dereference before null check'
This commit is contained in:
parent
b9104f38b8
commit
aa47903520
@ -69,63 +69,67 @@ void task_file_load_handler(retro_task_t *task)
|
||||
{
|
||||
nbio_handle_t *nbio = (nbio_handle_t*)task->state;
|
||||
|
||||
switch (nbio->status)
|
||||
if (nbio)
|
||||
{
|
||||
case NBIO_STATUS_INIT:
|
||||
if (nbio && !string_is_empty(nbio->path))
|
||||
{
|
||||
const char *fullpath = nbio->path;
|
||||
struct nbio_t *handle = nbio_open(fullpath, NBIO_READ);
|
||||
if (handle)
|
||||
switch (nbio->status)
|
||||
{
|
||||
case NBIO_STATUS_INIT:
|
||||
if (nbio && !string_is_empty(nbio->path))
|
||||
{
|
||||
nbio->handle = handle;
|
||||
nbio->status = NBIO_STATUS_TRANSFER;
|
||||
const char *fullpath = nbio->path;
|
||||
struct nbio_t *handle = nbio_open(fullpath, NBIO_READ);
|
||||
|
||||
if (strstr(fullpath, file_path_str(FILE_PATH_PNG_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_PNG;
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_JPEG_EXTENSION))
|
||||
|| strstr(fullpath, file_path_str(FILE_PATH_JPG_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_JPEG;
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_BMP_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_BMP;
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_TGA_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_TGA;
|
||||
if (handle)
|
||||
{
|
||||
nbio->handle = handle;
|
||||
nbio->status = NBIO_STATUS_TRANSFER;
|
||||
|
||||
nbio_begin_read(handle);
|
||||
return;
|
||||
if (strstr(fullpath, file_path_str(FILE_PATH_PNG_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_PNG;
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_JPEG_EXTENSION))
|
||||
|| strstr(fullpath, file_path_str(FILE_PATH_JPG_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_JPEG;
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_BMP_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_BMP;
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_TGA_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_TGA;
|
||||
|
||||
nbio_begin_read(handle);
|
||||
return;
|
||||
}
|
||||
else
|
||||
task_set_cancelled(task, true);
|
||||
}
|
||||
else
|
||||
break;
|
||||
case NBIO_STATUS_TRANSFER_PARSE:
|
||||
if (task_file_transfer_iterate_parse(nbio) == -1)
|
||||
task_set_cancelled(task, true);
|
||||
}
|
||||
break;
|
||||
case NBIO_STATUS_TRANSFER_PARSE:
|
||||
if (task_file_transfer_iterate_parse(nbio) == -1)
|
||||
task_set_cancelled(task, true);
|
||||
nbio->status = NBIO_STATUS_TRANSFER_PARSE_FREE;
|
||||
break;
|
||||
case NBIO_STATUS_TRANSFER:
|
||||
if (task_file_transfer_iterate_transfer(nbio) == -1)
|
||||
nbio->status = NBIO_STATUS_TRANSFER_PARSE;
|
||||
break;
|
||||
case NBIO_STATUS_TRANSFER_PARSE_FREE:
|
||||
case NBIO_STATUS_POLL:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
nbio->status = NBIO_STATUS_TRANSFER_PARSE_FREE;
|
||||
break;
|
||||
case NBIO_STATUS_TRANSFER:
|
||||
if (task_file_transfer_iterate_transfer(nbio) == -1)
|
||||
nbio->status = NBIO_STATUS_TRANSFER_PARSE;
|
||||
break;
|
||||
case NBIO_STATUS_TRANSFER_PARSE_FREE:
|
||||
case NBIO_STATUS_POLL:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (nbio->image_type)
|
||||
{
|
||||
case IMAGE_TYPE_PNG:
|
||||
case IMAGE_TYPE_JPEG:
|
||||
case IMAGE_TYPE_TGA:
|
||||
case IMAGE_TYPE_BMP:
|
||||
if (!task_image_load_handler(task))
|
||||
task_set_finished(task, true);
|
||||
break;
|
||||
case 0:
|
||||
if (nbio->is_finished)
|
||||
task_set_finished(task, true);
|
||||
break;
|
||||
switch (nbio->image_type)
|
||||
{
|
||||
case IMAGE_TYPE_PNG:
|
||||
case IMAGE_TYPE_JPEG:
|
||||
case IMAGE_TYPE_TGA:
|
||||
case IMAGE_TYPE_BMP:
|
||||
if (!task_image_load_handler(task))
|
||||
task_set_finished(task, true);
|
||||
break;
|
||||
case 0:
|
||||
if (nbio->is_finished)
|
||||
task_set_finished(task, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (task_get_cancelled(task))
|
||||
|
Loading…
Reference in New Issue
Block a user