Skip to content

Commit 667d610

Browse files
authored
[API] Fix nHasDragDropPayload SIGSEGV when payload doesn't exist (#155)
`getDragDropPayload()` functions should simply return null when the payload doesn't exist. Currently, DearImGui will return NULL from `ImGui::GetDragDropPayload()` when the payload does not exist. This causes a null dereference since the nHasDragDropPayload function performs no NULL check
1 parent 4f06b4e commit 667d610

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

imgui-binding/src/main/java/imgui/ImGui.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5118,11 +5118,13 @@ public static <T> T getDragDropPayload(final Class<T> aClass) {
51185118
}
51195119

51205120
private static native boolean nHasDragDropPayload(); /*
5121-
return ImGui::GetDragDropPayload()->Data != NULL;
5121+
const ImGuiPayload* payload = ImGui::GetDragDropPayload();
5122+
return payload != NULL && payload->Data != NULL;
51225123
*/
51235124

51245125
private static native boolean nHasDragDropPayload(String dataType); /*
5125-
return ImGui::GetDragDropPayload()->IsDataType(dataType);
5126+
const ImGuiPayload* payload = ImGui::GetDragDropPayload();
5127+
return payload != NULL && payload->IsDataType(dataType);
51265128
*/
51275129

51285130
/**

0 commit comments

Comments
 (0)