Skip to content

Commit

Permalink
Add check for input == NULL.
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveDavenport committed Jan 17, 2021
1 parent ca86eec commit 519b2a2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions source/helper.c
Expand Up @@ -1138,13 +1138,17 @@ char *helper_get_theme_path ( const char *file )
return filename;
}

static void parse_pair ( char *input, rofi_range_pair *item )
static gboolean parse_pair ( char *input, rofi_range_pair *item )
{
// Skip leading blanks.
while ( input != NULL && isblank ( *input ) ) {
++input;
}

if ( input == NULL ) {
return FALSE;
}

const char *sep[] = { "-", ":" };
int pythonic = ( strchr ( input, ':' ) || input[0] == '-' ) ? 1 : 0;
int index = 0;
Expand All @@ -1166,6 +1170,7 @@ static void parse_pair ( char *input, rofi_range_pair *item )
--item->stop;
}
}
return TRUE;
}
void parse_ranges ( char *input, rofi_range_pair **list, unsigned int *length )
{
Expand All @@ -1178,9 +1183,9 @@ void parse_ranges ( char *input, rofi_range_pair **list, unsigned int *length )
// Make space.
*list = g_realloc ( ( *list ), ( ( *length ) + 1 ) * sizeof ( struct rofi_range_pair ) );
// Parse a single pair.
parse_pair ( token, &( ( *list )[*length] ) );

( *length )++;
if ( parse_pair ( token, &( ( *list )[*length] ) ) ) {
( *length )++;
}
}
}
/**
Expand Down

0 comments on commit 519b2a2

Please sign in to comment.