diff options
Diffstat (limited to 'src/XF86DGA2.c')
-rw-r--r-- | src/XF86DGA2.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/XF86DGA2.c b/src/XF86DGA2.c index 8830266..b5145ee 100644 --- a/src/XF86DGA2.c +++ b/src/XF86DGA2.c @@ -356,9 +356,16 @@ XDGAMode* XDGAQueryModes( modes[i].reserved1 = info.reserved1; modes[i].reserved2 = info.reserved2; - _XRead(dpy, offset, info.name_size); - modes[i].name = offset; - offset += info.name_size; + if (info.name_size > 0 && info.name_size <= size) { + _XRead(dpy, offset, info.name_size); + modes[i].name = offset; + modes[i].name[info.name_size - 1] = '\0'; + offset += info.name_size; + size -= info.name_size; + } else { + _XEatData(dpy, info.name_size); + modes[i].name = NULL; + } } *num = rep.number; } else |