[FFmpeg-devel] [PATCH] Fix segfault in x11grab when drawing Cursor on Xservers that don't support the XFixes extension

Brenden Bain brenden.bain
Fri Jun 25 01:12:50 CEST 2010


2010/6/24 M?ns Rullg?rd <mans at mansr.com>:
> Brenden Bain <brenden.bain at gmail.com> writes:
>
>> Index: libavdevice/x11grab.c
>> ===================================================================
>> --- libavdevice/x11grab.c ? ? (revision 23755)
>> +++ libavdevice/x11grab.c ? ? (working copy)
>> @@ -91,7 +91,7 @@
>> ? ? ?XImage *image;
>> ? ? ?int x_off = 0;
>> ? ? ?int y_off = 0;
>> - ? ?int use_shm;
>> + ? ?int use_shm, ignore;
>> ? ? ?char *param, *offset;
>>
>> ? ? ?param = av_strdup(s1->filename);
>> @@ -115,6 +115,11 @@
>> ? ? ? ? ?return AVERROR(EIO);
>> ? ? ?}
>>
>> + ? ?if (!XFixesQueryExtension(dpy, &ignore, &ignore)) {
>> + ? ? ? ?av_log(s1, AV_LOG_INFO, "Disabling cursor recording. Unable to query cursor shape.\n");
>> + ? ? ? ?x11grab->nomouse = 1;
>> + ? ?}
>> +
>> ? ? ?st = av_new_stream(s1, 0);
>> ? ? ?if (!st) {
>> ? ? ? ? ?return AVERROR(ENOMEM);
>> @@ -245,8 +250,9 @@
>> ? * ? ? ? ? ?coordinates
>> ? * @param x Mouse pointer coordinate
>> ? * @param y Mouse pointer coordinate
>> + * @return 0 if an error occurred, 1 otherwise.
>
> Usual convention is 0 for success, negative for error.

Okay. Changed though this file seemed to use both in the past.

>> ? */
>> -static void
>> +static int
>> ?paint_mouse_pointer(XImage *image, struct x11_grab *s)
>> ?{
>> ? ? ?int x_off = s->x_off;
>> @@ -262,6 +268,10 @@
>>
>> ? ? ?xcim = XFixesGetCursorImage(dpy);
>>
>> + ? ?if (xcim == NULL) {
>> + ? ? ? ?return 0;
>> + ? ?}
>> +
>> ? ? ?x = xcim->x - xcim->xhot;
>> ? ? ?y = xcim->y - xcim->yhot;
>>
>> @@ -284,6 +294,7 @@
>>
>> ? ? ?XFree(xcim);
>> ? ? ?xcim = NULL;
>> + ? ?return 1;
>> ?}
>>
>>
>> @@ -388,7 +399,11 @@
>> ? ? ?}
>>
>> ? ? ?if(!s->nomouse){
>> - ? ? ? ?paint_mouse_pointer(image, s);
>> + ? ? ? ?if (!paint_mouse_pointer(image, s)) {
>> + ? ? ? ? ? ?/* An error occured and will likely occur again. Just disable mouse capture from now on */
>
> That comment is superfluous. ?Anyone with half a brain can see pointer
> capture is being turned off.

Done.

Brenden.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x11_segfault_fix.patch
Type: text/x-patch
Size: 1536 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100625/b7ee8c8f/attachment.bin>



More information about the ffmpeg-devel mailing list