Fix id in error when resource does not exist
Always set client->errorValue before returning an error.
Test program:
int main(int argc, char *argv[]) {
    int screen = 0;
    xcb_connection_t *c = xcb_connect(NULL, &screen);
    if (!c) {
        printf("Cannot connect\n");
        return 1;
    }
    xcb_void_cookie_t tok = xcb_free_gc_checked(c, BAD_VALUE);
    xcb_g_context_error_t *err = (xcb_g_context_error_t *)xcb_request_check(c, tok);
    if (!err) {
        printf("Unexpected request success\n");
        return 1;
    }
    if (err->bad_value != BAD_VALUE) {
        printf("Error: Got 0x%X, expected 0x%X\n", err->bad_value, BAD_VALUE);
        return 1;
    }
    printf("Success! Got expected bad value of 0x%X\n", BAD_VALUE);
    return 0;
}
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
			
			
This commit is contained in:
		
							parent
							
								
									f4a4115547
								
							
						
					
					
						commit
						97a8353ec1
					
				| 
						 | 
					@ -1220,11 +1220,13 @@ dixLookupResourceByType(void **result, XID id, RESTYPE rtype,
 | 
				
			||||||
            if (res->id == id && res->type == rtype)
 | 
					            if (res->id == id && res->type == rtype)
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    if (client) {
 | 
				
			||||||
 | 
					        client->errorValue = id;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if (!res)
 | 
					    if (!res)
 | 
				
			||||||
        return resourceTypes[rtype & TypeMask].errorValue;
 | 
					        return resourceTypes[rtype & TypeMask].errorValue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (client) {
 | 
					    if (client) {
 | 
				
			||||||
        client->errorValue = id;
 | 
					 | 
				
			||||||
        cid = XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type,
 | 
					        cid = XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type,
 | 
				
			||||||
                       res->value, RT_NONE, NULL, mode);
 | 
					                       res->value, RT_NONE, NULL, mode);
 | 
				
			||||||
        if (cid == BadValue)
 | 
					        if (cid == BadValue)
 | 
				
			||||||
| 
						 | 
					@ -1253,11 +1255,13 @@ dixLookupResourceByClass(void **result, XID id, RESTYPE rclass,
 | 
				
			||||||
            if (res->id == id && (res->type & rclass))
 | 
					            if (res->id == id && (res->type & rclass))
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    if (client) {
 | 
				
			||||||
 | 
					        client->errorValue = id;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if (!res)
 | 
					    if (!res)
 | 
				
			||||||
        return BadValue;
 | 
					        return BadValue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (client) {
 | 
					    if (client) {
 | 
				
			||||||
        client->errorValue = id;
 | 
					 | 
				
			||||||
        cid = XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type,
 | 
					        cid = XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type,
 | 
				
			||||||
                       res->value, RT_NONE, NULL, mode);
 | 
					                       res->value, RT_NONE, NULL, mode);
 | 
				
			||||||
        if (cid != Success)
 | 
					        if (cid != Success)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue