mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-30 16:37:39 +00:00
Fixed uninitialized signal_id
Also removed unnecessary SDL_OutOfMemory() calls Fixes https://github.com/libsdl-org/SDL/issues/9300
This commit is contained in:
parent
90e2551c4f
commit
491f18eea3
1 changed files with 10 additions and 12 deletions
|
@ -263,7 +263,7 @@ static void DBus_OpenDialog(const char *method, const char *method_title, SDL_Di
|
||||||
SDL_DBusContext *dbus = SDL_DBus_GetContext();
|
SDL_DBusContext *dbus = SDL_DBus_GetContext();
|
||||||
DBusMessage *msg;
|
DBusMessage *msg;
|
||||||
DBusMessageIter params, options;
|
DBusMessageIter params, options;
|
||||||
const char *signal_id;
|
const char *signal_id = NULL;
|
||||||
char *handle_str, *filter;
|
char *handle_str, *filter;
|
||||||
int filter_len;
|
int filter_len;
|
||||||
static uint32_t handle_id = 0;
|
static uint32_t handle_id = 0;
|
||||||
|
@ -271,13 +271,13 @@ static void DBus_OpenDialog(const char *method, const char *method_title, SDL_Di
|
||||||
SDL_PropertiesID props = SDL_GetWindowProperties(window);
|
SDL_PropertiesID props = SDL_GetWindowProperties(window);
|
||||||
|
|
||||||
if (dbus == NULL) {
|
if (dbus == NULL) {
|
||||||
SDL_SetError("%s", "Failed to connect to DBus!");
|
SDL_SetError("Failed to connect to DBus");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = dbus->message_new_method_call(PORTAL_DESTINATION, PORTAL_PATH, PORTAL_INTERFACE, method);
|
msg = dbus->message_new_method_call(PORTAL_DESTINATION, PORTAL_PATH, PORTAL_INTERFACE, method);
|
||||||
if (msg == NULL) {
|
if (msg == NULL) {
|
||||||
SDL_SetError("%s", "Failed to send message to portal!");
|
SDL_SetError("Failed to send message to portal");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +320,6 @@ static void DBus_OpenDialog(const char *method, const char *method_title, SDL_Di
|
||||||
|
|
||||||
handle_str = SDL_malloc(sizeof(char) * (HANDLE_LEN + 1));
|
handle_str = SDL_malloc(sizeof(char) * (HANDLE_LEN + 1));
|
||||||
if (!handle_str) {
|
if (!handle_str) {
|
||||||
SDL_OutOfMemory();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SDL_snprintf(handle_str, HANDLE_LEN, "%u", ++handle_id);
|
SDL_snprintf(handle_str, HANDLE_LEN, "%u", ++handle_id);
|
||||||
|
@ -347,20 +346,21 @@ static void DBus_OpenDialog(const char *method, const char *method_title, SDL_Di
|
||||||
DBusMessageIter reply_iter;
|
DBusMessageIter reply_iter;
|
||||||
dbus->message_iter_init(reply, &reply_iter);
|
dbus->message_iter_init(reply, &reply_iter);
|
||||||
|
|
||||||
if (dbus->message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_OBJECT_PATH)
|
if (dbus->message_iter_get_arg_type(&reply_iter) == DBUS_TYPE_OBJECT_PATH) {
|
||||||
{
|
|
||||||
SDL_SetError("%s", "Invalid response received by DBus!");
|
|
||||||
goto incorrect_type;
|
|
||||||
}
|
|
||||||
dbus->message_iter_get_basic(&reply_iter, &signal_id);
|
dbus->message_iter_get_basic(&reply_iter, &signal_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!signal_id) {
|
||||||
|
SDL_SetError("Invalid response received by DBus");
|
||||||
|
goto incorrect_type;
|
||||||
|
}
|
||||||
|
|
||||||
dbus->message_unref(msg);
|
dbus->message_unref(msg);
|
||||||
|
|
||||||
filter_len = SDL_strlen(SIGNAL_FILTER) + SDL_strlen(signal_id) + 2;
|
filter_len = SDL_strlen(SIGNAL_FILTER) + SDL_strlen(signal_id) + 2;
|
||||||
filter = SDL_malloc(sizeof(char) * filter_len);
|
filter = SDL_malloc(sizeof(char) * filter_len);
|
||||||
if (!filter) {
|
if (!filter) {
|
||||||
SDL_OutOfMemory();
|
|
||||||
goto incorrect_type;
|
goto incorrect_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,14 +370,12 @@ static void DBus_OpenDialog(const char *method, const char *method_title, SDL_Di
|
||||||
|
|
||||||
SignalCallback *data = SDL_malloc(sizeof(SignalCallback));
|
SignalCallback *data = SDL_malloc(sizeof(SignalCallback));
|
||||||
if (!data) {
|
if (!data) {
|
||||||
SDL_OutOfMemory();
|
|
||||||
goto incorrect_type;
|
goto incorrect_type;
|
||||||
}
|
}
|
||||||
data->callback = callback;
|
data->callback = callback;
|
||||||
data->userdata = userdata;
|
data->userdata = userdata;
|
||||||
data->path = SDL_strdup(signal_id);
|
data->path = SDL_strdup(signal_id);
|
||||||
if (!data->path) {
|
if (!data->path) {
|
||||||
SDL_OutOfMemory();
|
|
||||||
SDL_free(data);
|
SDL_free(data);
|
||||||
goto incorrect_type;
|
goto incorrect_type;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue