From: David Maciejak <[email protected]>

This patch is used to catch some return function value, to avoid possible
misbehaviour, as reported by the compiler.
---
 WPrefs.app/Appearance.c    | 16 ++++++++++++----
 WPrefs.app/MouseSettings.c |  3 ++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/WPrefs.app/Appearance.c b/WPrefs.app/Appearance.c
index 3bd571a..ec71ee4 100644
--- a/WPrefs.app/Appearance.c
+++ b/WPrefs.app/Appearance.c
@@ -1261,17 +1261,25 @@ static Pixmap loadRImage(WMScreen * scr, const char 
*path)
 {
        FILE *f;
        RImage *image;
-       int w, h, d;
+       int w, h, d, cnt;
+       size_t read_size;
        Pixmap pixmap;
 
        f = fopen(path, "rb");
        if (!f)
                return None;
 
-       fscanf(f, "%02x%02x%1x", &w, &h, &d);
-
+       cnt = fscanf(f, "%02x%02x%1x", &w, &h, &d);
+       if (cnt != 3) {
+               fclose(f);
+               return None;
+       }
        image = RCreateImage(w, h, d == 4);
-       fread(image->data, 1, w * h * d, f);
+       read_size = w * h * d;
+       if (fread(image->data, 1, read_size, f) != read_size) {
+               fclose(f);
+               return None;
+       }
        fclose(f);
 
        RConvertImage(WMScreenRContext(scr), image, &pixmap);
diff --git a/WPrefs.app/MouseSettings.c b/WPrefs.app/MouseSettings.c
index 2aa500b..31d467d 100644
--- a/WPrefs.app/MouseSettings.c
+++ b/WPrefs.app/MouseSettings.c
@@ -714,7 +714,8 @@ static void storeCommandInScript(const char *cmd, const 
char *line)
                wfree(tmppath);
        }
        sprintf(buffer, "chmod u+x %s", path);
-       system(buffer);
+       if (system(buffer) == -1)
+               werror(_("could not execute command \"%s\""), buffer);
 
  end:
        wfree(path);
-- 
1.8.5.3


-- 
To unsubscribe, send mail to [email protected].

Reply via email to