Bug 10846

Summary: wrong XF86VidModeGetMonitor description
Product: xorg Reporter: Werner Meisner <weme24>
Component: * OtherAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium    
Version: 7.2 (2007.02)   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 10101    

Description Werner Meisner 2007-05-03 07:58:40 UTC
from  the man-page of XF86VidModeGetMonitor:

  MONITOR FUNCTIONS
       Information  known  to the server about the monitor is returned by the XF
       function.  The hsync and vsync fields each point to an array of XF86VidMo
       tures.   The arrays contain nhsync and nvsync elements, respectively.  Th
       will be equal if a discreate value was given in the XF86Config file.

       The vendor, model, hsync, and vsync fields  point  to  dynamically  alloc
       should be freed by the caller.

dynamically allocated ??
not really

from XF86VMode.c

    if (rep.vendorLength)
        _XReadPad(dpy, monitor->vendor, rep.vendorLength);
    else
        monitor->vendor = "";
    if (rep.modelLength)
        _XReadPad(dpy, monitor->model, rep.modelLength);
    else
        monitor->model = "";
        
a pointer to a static "" is not dynamically!!
so

    XF86VidModeGetMonitor(dpy, DefaultScreen(dpy), &monitor)

    XFree(monitor.vendor);   -> crash
    XFree(monitor.model);    -> crash



were does the problem arise: xdpyinfo

   [...]
   XFree86-VidModeExtension version 2.2 opcode: 134, base error: 130
     Monitor Information:
       Vendor: , Model: 
       Num hsync: 1, Num vsync: 1
       hsync range 0:  30.00 -  70.00
       vsync range 0:  47.00 -  85.00
   *** glibc detected *** ./xdpyinfo: munmap_chunk(): invalid pointer: 0xb7ec794
Comment 1 Adam Jackson 2008-03-24 12:13:54 UTC
Fixed in git, thanks!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.