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

[Dmenu] Fix possible crash.

Don't pass empty string.

Issue: #1083
This commit is contained in:
Dave Davenport 2020-04-06 23:26:07 +02:00
parent 825fe4ae58
commit f63da72ea6
3 changed files with 30 additions and 2 deletions

View file

@ -249,6 +249,16 @@ double rofi_theme_get_double ( const widget *widget, const char *property, doub
*/
void rofi_theme_get_color ( const widget *widget, const char *property, cairo_t *d );
/**
* @param widget The widget to query
* @param property The property to query.
*
* Check if a rofi theme has a property set.
*
*/
gboolean rofi_theme_has_property ( const widget *widget, const char *property );
/**
* @param widget The widget to query
* @param property The property to query.

View file

@ -77,10 +77,11 @@ typedef struct
void dmenuscript_parse_entry_extras ( G_GNUC_UNUSED Mode *sw, DmenuScriptEntry *entry, char *buffer, size_t length )
{
size_t length_key = 0; //strlen ( line );
while ( length_key <= length && buffer[length_key] != '\x1f' ) {
while ( length_key < length && buffer[length_key] != '\x1f' ) {
length_key++;
}
if ( length_key < length ) {
// Should be not last character in buffer.
if ( length_key < (length-1) ) {
buffer[length_key] = '\0';
char *value = buffer + length_key + 1;
if ( strcasecmp ( buffer, "icon" ) == 0 ) {

View file

@ -1158,3 +1158,20 @@ ThemeMediaType rofi_theme_parse_media_type ( const char *type )
}
return THEME_MEDIA_TYPE_INVALID;
}
gboolean rofi_theme_has_property ( const widget *widget, const char *property )
{
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state, FALSE );
Property *p = rofi_theme_find_property ( wid, P_STRING, property, FALSE );
if ( p ) {
if ( p->type == P_INHERIT ) {
if ( widget->parent ) {
return rofi_theme_has_property ( widget->parent, property );
}
return FALSE;
}
return TRUE;
}
return FALSE;
}