Skip to content

Commit de021c8

Browse files
authored
Fix glfw crashes when passing null for optional output arguments of some functions (#11157)
Do not write output values when optional output pointer is null for calls of following functions: glfwGetFramebufferSize (width/height) glfwGetWindowSize (width/height) glfwGetWindowPos (x/y) This is in pair with native GLFW 3.2 implementation and documentation for these functions.
1 parent 5532b9e commit de021c8

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,3 +471,4 @@ a license to everyone to use it as detailed in LICENSE.)
471471
* Shachar Langbeheim <[email protected]>
472472
* David Carlier <[email protected]>
473473
* Paul Du <[email protected]> (copyright owned by ARSKAN)
474+
* Piotr Doan <[email protected]>

src/library_glfw.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,13 @@ var LibraryGLFW = {
916916
wy = win.y;
917917
}
918918

919-
setValue(x, wx, 'i32');
920-
setValue(y, wy, 'i32');
919+
if (x) {
920+
setValue(x, wx, 'i32');
921+
}
922+
923+
if (y) {
924+
setValue(y, wy, 'i32');
925+
}
921926
},
922927

923928
setWindowPos: function(winid, x, y) {
@@ -937,8 +942,13 @@ var LibraryGLFW = {
937942
wh = win.height;
938943
}
939944

940-
setValue(width, ww, 'i32');
941-
setValue(height, wh, 'i32');
945+
if (width) {
946+
setValue(width, ww, 'i32');
947+
}
948+
949+
if (height) {
950+
setValue(height, wh, 'i32');
951+
}
942952
},
943953

944954
setWindowSize: function(winid, width, height) {
@@ -1331,9 +1341,14 @@ var LibraryGLFW = {
13311341
ww = win.width;
13321342
wh = win.height;
13331343
}
1334-
1335-
setValue(width, ww, 'i32');
1336-
setValue(height, wh, 'i32');
1344+
1345+
if (width) {
1346+
setValue(width, ww, 'i32');
1347+
}
1348+
1349+
if (height) {
1350+
setValue(height, wh, 'i32');
1351+
}
13371352
},
13381353

13391354
glfwIconifyWindow: function(winid) {

0 commit comments

Comments
 (0)