[dev] [st][PATCH] unsigned function tdefcolor returns -1 on error

From: Eon S. Jeon <esjeon_AT_lavabit.com>
Date: Sun, 4 Aug 2013 08:54:35 -0400

Hi

I found that tdefcolor returns -1 on error, while its return type is
unsigned long. At the same time, line 1724 and 1731 are checking the
positivity of its unsigned return value.

Since the actual color values are 24 bits long, it should be okay to
cast the return value to long before checking its positivity.

Regards
Eon


diff --git a/st.c b/st.c
index 362de23..e8fd92e 100644
--- a/st.c
+++ b/st.c
_AT_@ -1721,14 +1721,14 @@ tsetattr(int *attr, int l) {
                         term.c.attr.mode &= ~ATTR_REVERSE;
                         break;
                 case 38:
- if ((idx = tdefcolor(attr, &i, l)) >= 0)
+ if ((long)(idx = tdefcolor(attr, &i, l)) >= 0)
                                 term.c.attr.fg = idx;
                         break;
                 case 39:
                         term.c.attr.fg = defaultfg;
                         break;
                 case 48:
- if ((idx = tdefcolor(attr, &i, l)) >= 0)
+ if ((long)(idx = tdefcolor(attr, &i, l)) >= 0)
                                 term.c.attr.bg = idx;
                         break;
                 case 49:
Received on Sun Aug 04 2013 - 14:54:35 CEST

This archive was generated by hypermail 2.3.0 : Sun Aug 04 2013 - 15:00:08 CEST