mirror of https://github.com/davatorium/rofi.git
Use snprintf instead of sprintf
This commit is contained in:
parent
d7dab65e5b
commit
c6a9de8c4a
|
@ -451,10 +451,10 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
|
||||||
desktops = 1;
|
desktops = 1;
|
||||||
}
|
}
|
||||||
if ( pd->config_i3_mode ) {
|
if ( pd->config_i3_mode ) {
|
||||||
sprintf ( pattern, "%%-%ds %%s", MAX ( 5, classfield ) );
|
snprintf ( pattern, 50, "%%-%ds %%s", MAX ( 5, classfield ) );
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
sprintf ( pattern, "%%-%ds %%-%ds %%s", desktops < 10 ? 1 : 2,
|
snprintf ( pattern, 50, "%%-%ds %%-%ds %%s", desktops < 10 ? 1 : 2,
|
||||||
MAX ( 5, classfield ) );
|
MAX ( 5, classfield ) );
|
||||||
}
|
}
|
||||||
pd->cmd_list = g_malloc0_n ( ( pd->ids->len + 1 ), sizeof ( char* ) );
|
pd->cmd_list = g_malloc0_n ( ( pd->ids->len + 1 ), sizeof ( char* ) );
|
||||||
|
@ -469,7 +469,8 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
|
||||||
unsigned long wmdesktop;
|
unsigned long wmdesktop;
|
||||||
char desktop[5];
|
char desktop[5];
|
||||||
desktop[0] = 0;
|
desktop[0] = 0;
|
||||||
char *line = g_malloc ( strlen ( c->title ) + strlen ( c->class ) + classfield + 50 );
|
size_t len = strlen ( c->title ) + strlen ( c->class ) + classfield + 50;
|
||||||
|
char *line = g_malloc ( len );
|
||||||
if ( !pd->config_i3_mode ) {
|
if ( !pd->config_i3_mode ) {
|
||||||
// find client's desktop.
|
// find client's desktop.
|
||||||
if ( !window_get_cardinal_prop ( display, c->window, netatoms[_NET_WM_DESKTOP], &wmdesktop, 1 ) ) {
|
if ( !window_get_cardinal_prop ( display, c->window, netatoms[_NET_WM_DESKTOP], &wmdesktop, 1 ) ) {
|
||||||
|
@ -482,13 +483,13 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( wmdesktop < 0xFFFFFFFF ) {
|
if ( wmdesktop < 0xFFFFFFFF ) {
|
||||||
sprintf ( desktop, "%d", (int) wmdesktop );
|
snprintf ( desktop, 5, "%d", (int) wmdesktop );
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf ( line, pattern, desktop, c->class, c->title );
|
snprintf ( line, len, pattern, desktop, c->class, c->title );
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
sprintf ( line, pattern, c->class, c->title );
|
snprintf ( line, len, pattern, c->class, c->title );
|
||||||
}
|
}
|
||||||
|
|
||||||
pd->cmd_list[pd->cmd_list_length++] = line;
|
pd->cmd_list[pd->cmd_list_length++] = line;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
|
|
||||||
|
|
||||||
int widget_intersect ( const Widget *widget, int x, int y )
|
int widget_intersect ( const Widget *widget, int x, int y )
|
||||||
{
|
{
|
||||||
if ( widget == NULL ) {
|
if ( widget == NULL ) {
|
||||||
|
@ -14,7 +13,6 @@ int widget_intersect ( const Widget *widget, int x, int y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void widget_move ( Widget *widget, short x, short y )
|
void widget_move ( Widget *widget, short x, short y )
|
||||||
|
@ -23,5 +21,4 @@ void widget_move(Widget *widget, short x, short y)
|
||||||
widget->x = x;
|
widget->x = x;
|
||||||
widget->y = y;
|
widget->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue