summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2020-04-06 23:26:07 +0200
committerDave Davenport <qball@gmpclient.org>2020-04-06 23:31:45 +0200
commitf63da72ea6fab13279e0fe437929ce4434f63c9f (patch)
tree687be3d0dd8505c02c0d75398e143668282fa5cb
parent825fe4ae58e169f92ce940b672054e9fbdefb1ad (diff)
[Dmenu] Fix possible crash.
Don't pass empty string. Issue: #1083
-rw-r--r--include/theme.h10
-rw-r--r--source/dialogs/script.c5
-rw-r--r--source/theme.c17
3 files changed, 30 insertions, 2 deletions
diff --git a/include/theme.h b/include/theme.h
index 751d83b3..0ed71460 100644
--- a/include/theme.h
+++ b/include/theme.h
@@ -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.
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;
+}