File tree 2 files changed +29
-1
lines changed 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ bool GetNvidiaDriverVersionWithXNVCtrl(std::string *version)
30
30
31
31
Display *display = XOpenDisplay (nullptr );
32
32
33
- if (XNVCTRLQueryExtension (display, &eventBase, &errorBase))
33
+ if (display && XNVCTRLQueryExtension (display, &eventBase, &errorBase))
34
34
{
35
35
int screenCount = ScreenCount (display);
36
36
for (int screen = 0 ; screen < screenCount; ++screen)
Original file line number Diff line number Diff line change 12
12
#include < iostream>
13
13
14
14
#include " common/platform.h"
15
+ #include " common/system_utils.h"
15
16
#include " gpu_info_util/SystemInfo.h"
16
17
17
18
using namespace angle ;
@@ -99,4 +100,31 @@ TEST(PrintSystemInfoTest, Print)
99
100
#endif
100
101
}
101
102
103
+ TEST (PrintSystemInfoTest, GetSystemInfoNoCrashOnInvalidDisplay)
104
+ {
105
+ #if defined(SYSTEM_INFO_IMPLEMENTED) && defined(ANGLE_USE_X11)
106
+ const char kX11DisplayEnvVar [] = " DISPLAY" ;
107
+ const char kInvalidDisplay [] = " 124:" ;
108
+ std::string previous_display = GetEnvironmentVar (kX11DisplayEnvVar );
109
+ SetEnvironmentVar (kX11DisplayEnvVar , kInvalidDisplay );
110
+ SystemInfo info;
111
+
112
+ // This should not crash.
113
+ GetSystemInfo (&info);
114
+
115
+ if (previous_display.empty ())
116
+ {
117
+ UnsetEnvironmentVar (kX11DisplayEnvVar );
118
+ }
119
+ else
120
+ {
121
+ SetEnvironmentVar (kX11DisplayEnvVar , previous_display.c_str ());
122
+ }
123
+ #elif defined(SYSTEM_INFO_IMPLEMENTED)
124
+ std::cerr << " GetSystemInfo not implemented, skipping" << std::endl;
125
+ #else
126
+ std::cerr << " GetSystemInfo X11 test not applicable, skipping" << std::endl;
127
+ #endif
128
+ }
129
+
102
130
} // anonymous namespace
You can’t perform that action at this time.
0 commit comments