mirror of
https://github.com/libretro/mgba.git
synced 2024-11-29 03:00:31 +00:00
Make driver loading signal failure, and fix case where setting a driver can cause a null pointer deref
This commit is contained in:
parent
043d396320
commit
a2a3f317b5
@ -83,9 +83,13 @@ void GBASIOSetDriver(struct GBASIO* sio, struct GBASIODriver* driver, enum GBASI
|
||||
driver->p = sio;
|
||||
|
||||
if (driver->init) {
|
||||
driver->init(driver);
|
||||
if (!driver->init(driver)) {
|
||||
driver->deinit(driver);
|
||||
GBALog(sio->p, GBA_LOG_ERROR, "Could not initialize SIO driver");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (*driverLoc == sio->activeDriver) {
|
||||
if (*driverLoc && *driverLoc == sio->activeDriver) {
|
||||
sio->activeDriver = driver;
|
||||
if ((*driverLoc)->load) {
|
||||
(*driverLoc)->load(*driverLoc);
|
||||
|
@ -21,11 +21,11 @@ struct GBASIO;
|
||||
struct GBASIODriver {
|
||||
struct GBASIO* p;
|
||||
|
||||
void (*init)(struct GBASIODriver* driver);
|
||||
int (*init)(struct GBASIODriver* driver);
|
||||
void (*deinit)(struct GBASIODriver* driver);
|
||||
int (*load)(struct GBASIODriver* driver);
|
||||
int (*unload)(struct GBASIODriver* driver);
|
||||
void (*writeRegister)(struct GBASIODriver* driver, uint32_t address, uint16_t value);
|
||||
int (*writeRegister)(struct GBASIODriver* driver, uint32_t address, uint16_t value);
|
||||
int32_t (*processEvents)(struct GBASIODriver* driver, int32_t cycles);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user