1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

Return NULL when empty property.

This commit is contained in:
Dave Davenport 2016-03-04 19:41:32 +01:00
parent fa7ceaf580
commit 881ca572df
2 changed files with 13 additions and 8 deletions

View file

@ -89,11 +89,14 @@ char* window_get_text_prop ( xcb_window_t w, xcb_atom_t atom )
xcb_get_property_cookie_t c = xcb_get_property ( xcb->connection, 0, w, atom, XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX ); xcb_get_property_cookie_t c = xcb_get_property ( xcb->connection, 0, w, atom, XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX );
xcb_get_property_reply_t *r = xcb_get_property_reply ( xcb->connection, c, NULL ); xcb_get_property_reply_t *r = xcb_get_property_reply ( xcb->connection, c, NULL );
if ( r ) { if ( r ) {
char *str = g_malloc ( xcb_get_property_value_length ( r ) + 1 ); if ( xcb_get_property_value_length ( r ) > 0 ) {
memcpy ( str, xcb_get_property_value ( r ), xcb_get_property_value_length ( r ) ); char *str = g_malloc ( xcb_get_property_value_length ( r ) + 1 );
str[xcb_get_property_value_length ( r )] = '\0'; memcpy ( str, xcb_get_property_value ( r ), xcb_get_property_value_length ( r ) );
str[xcb_get_property_value_length ( r )] = '\0';
free ( r );
return str;
}
free ( r ); free ( r );
return str;
} }
return NULL; return NULL;
} }

View file

@ -333,10 +333,12 @@ static void __config_parse_xresource_options_dynamic ( XrmDatabase xDB )
void config_parse_xresource_options_dynamic ( xcb_stuff *xcb ) void config_parse_xresource_options_dynamic ( xcb_stuff *xcb )
{ {
char *name = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), XCB_ATOM_RESOURCE_MANAGER ); char *name = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), XCB_ATOM_RESOURCE_MANAGER );
XrmDatabase xDB = XrmGetStringDatabase ( name ); if ( name ) {
__config_parse_xresource_options_dynamic ( xDB ); XrmDatabase xDB = XrmGetStringDatabase ( name );
XrmDestroyDatabase ( xDB ); __config_parse_xresource_options_dynamic ( xDB );
g_free ( name ); XrmDestroyDatabase ( xDB );
g_free ( name );
}
} }
void config_parse_xresource_options_dynamic_file ( const char *filename ) void config_parse_xresource_options_dynamic_file ( const char *filename )
{ {