Skip to content

Commit ad70442

Browse files
jcowgilleXpl0it3r
authored andcommitted
Do not cache atom name if XInternAtom fails
If `XInternAtom` is called with `onlyIfExists` set, then it can legitimately return `None`. We should not cache this value because it might change in the future. This bug can sometimes be triggered because we use `getAtom("UTF8_STRING", true)` and `getAtom("UTF8_STRING")`. If the first call caches `None` because the atom didn't exist, then the second call could return `None` instead of creating a new atom like it should.
1 parent f88b768 commit ad70442

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/SFML/Window/Unix/Display.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ Atom getAtom(const std::string& name, bool onlyIfExists)
129129

130130
const auto display = openDisplay();
131131
const Atom atom = XInternAtom(display.get(), name.c_str(), onlyIfExists ? True : False);
132-
atoms[name] = atom;
132+
if (atom)
133+
atoms[name] = atom;
133134

134135
return atom;
135136
}

0 commit comments

Comments
 (0)