Fix logic in file open (should NOT allocate new ID if open fails.
This commit is contained in:
parent
c31e3b38ad
commit
4bdbaceccc
@ -55,33 +55,27 @@ int guac_rdpdr_fs_open(guac_rdpdr_device* device, const char* path) {
|
|||||||
|
|
||||||
guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data;
|
guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data;
|
||||||
|
|
||||||
/* If files available, allocate a new file ID */
|
int file_id;
|
||||||
if (data->open_files < GUAC_RDPDR_FS_MAX_FILES) {
|
guac_rdpdr_fs_file* file;
|
||||||
|
|
||||||
/* Get file ID */
|
/* If no files available, return too many open */
|
||||||
int file_id = guac_pool_next_int(data->file_id_pool);
|
if (data->open_files >= GUAC_RDPDR_FS_MAX_FILES)
|
||||||
guac_rdpdr_fs_file* file = &(data->files[file_id]);
|
return -1;
|
||||||
|
|
||||||
data->open_files++;
|
/* If path is empty, the file does not exist */
|
||||||
|
if (path[0] == '\0')
|
||||||
|
return -2;
|
||||||
|
|
||||||
/* If path is empty, it refers to the volume itself */
|
file->type = GUAC_RDPDR_FS_FILE;
|
||||||
if (path[0] == '\0')
|
/* STUB */
|
||||||
return -2;
|
|
||||||
|
|
||||||
/* Otherwise, parse path */
|
/* Get file ID */
|
||||||
else {
|
file_id = guac_pool_next_int(data->file_id_pool);
|
||||||
|
file = &(data->files[file_id]);
|
||||||
|
|
||||||
file->type = GUAC_RDPDR_FS_FILE;
|
data->open_files++;
|
||||||
/* STUB */
|
|
||||||
|
|
||||||
}
|
return file_id;
|
||||||
|
|
||||||
return file_id;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Otherwise, no file IDs available */
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user