> -----Original Message----- > > BTW, I just looked at one of the assert commits, and found it actually > _introduces_ a bug. > Look at the assert(attrib_list) added in > 706fffbff59be0dc884e1938f1bdf731af1efa3e. > > This ends up asserting that the attrib_list in glXCreatePixmap is not > NULL. > But the GLX specification says that it can be NULL, and it will usually > be. > > The memcpy does not crash because when attrib_list is NULL, the length > parameter passed to it is 0, as the code before shows. > > Thus, that commit should be reverted, and replaced with either no > change or by surrounding the memcpy with if(attrib_list) or if(i) . > Ideally, we could also mark the if, as well as the if(attrib_list) > above with unlikely() while we are at it. >
Whether this was a bug or not is subject to interpretation of the C specification. While it doesn't explicitly state so, a reading of the C99 specification sections 7.1.4 (Use of Library functions) and 7.21.1 (String function conventions) suggests that 'memcpy(dst, NULL, 0)' is undefined behavior. <quote> 7.21.1 String function conventions Where an argument declared as size_t n specifies the length of the array for a function, n can have the value zero on a call to that function. Unless explicitly stated otherwise in the description of a particular function in this subclause, pointer arguments on such a call shall still have valid values, as described in 7.1.4. On such a call, a function that locates a character finds no occurrence, a function that compares two character sequences returns zero, and a function that copies characters copies zero characters. </quote> ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Mesa3d-dev mailing list Mesa3d-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mesa3d-dev