qulogic/libgnt

3dacd4028a3e
Parents 1c91f3535e09
Children bf1681ecc819
Fix some issues pvs-studio found in gntwm.c
  • +16 -8
    gntwm.c
  • --- a/gntwm.c Thu Oct 03 06:13:03 2019 -0500
    +++ b/gntwm.c Thu Oct 03 06:35:19 2019 -0500
    @@ -216,7 +216,6 @@
    PANEL *panel = NULL;
    while ((panel = panel_below(panel)) != NULL) {
    int sx, ex, sy, ey, w, y;
    - cchar_t ch;
    PANEL *below = panel;
    sx = getbegx(panel_window(panel));
    @@ -232,6 +231,8 @@
    ex < getbegx(panel_window(below)))
    continue;
    for (y = MAX(sy, getbegy(panel_window(below))); y <= MIN(ey, getbegy(panel_window(below)) + getmaxy(panel_window(below))); y++) {
    + cchar_t ch;
    + memset(&ch, 0, sizeof(ch));
    if (mvwin_wch(panel_window(below), y - getbegy(panel_window(below)), sx - 1 - getbegx(panel_window(below)), &ch) != OK)
    goto right;
    w = widestringwidth(ch.chars);
    @@ -826,6 +827,7 @@
    #else
    cchar_t wch;
    char unicode[12];
    + memset(&wch, 0, sizeof(wch));
    mvwin_wch(curscr, y, x, &wch);
    now = wch.attr;
    ch[0] = (char)(wch.chars[0] & 0xff);
    @@ -1079,15 +1081,21 @@
    static int
    widestringwidth(wchar_t *wide)
    {
    - int len, ret;
    - char *string;
    + gint len;
    + gchar *str;
    len = wcstombs(NULL, wide, 0) + 1;
    - string = g_new0(char, len);
    - wcstombs(string, wide, len);
    - ret = string ? gnt_util_onscreen_width(string, NULL) : 1;
    - g_free(string);
    - return ret;
    + str = g_new0(char, len);
    + if(str != NULL) {
    + gint ret;
    + wcstombs(str, wide, len);
    + ret = gnt_util_onscreen_width(str, NULL);
    + g_free(str);
    +
    + return ret;
    + }
    +
    + return 1;
    }
    #endif