diff options
author | Dave Davenport <qball@gmpclient.org> | 2020-04-06 23:26:07 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2020-04-06 23:31:45 +0200 |
commit | f63da72ea6fab13279e0fe437929ce4434f63c9f (patch) | |
tree | 687be3d0dd8505c02c0d75398e143668282fa5cb /source | |
parent | 825fe4ae58e169f92ce940b672054e9fbdefb1ad (diff) |
[Dmenu] Fix possible crash.
Don't pass empty string.
Issue: #1083
Diffstat (limited to 'source')
-rw-r--r-- | source/dialogs/script.c | 5 | ||||
-rw-r--r-- | source/theme.c | 17 |
2 files changed, 20 insertions, 2 deletions
diff --git a/source/dialogs/script.c b/source/dialogs/script.c index db5e6c96..1991ac3e 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -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 ) { diff --git a/source/theme.c b/source/theme.c index 85062f8c..069b9ef3 100644 --- a/source/theme.c +++ b/source/theme.c @@ -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; +} |