[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-diffutils] [PATCH] diff: avoid possible longjmp-triggered misbehavi

From: Jim Meyering
Subject: [bug-diffutils] [PATCH] diff: avoid possible longjmp-triggered misbehavior
Date: Tue, 28 Aug 2012 11:08:00 +0200

a very recent gcc 4.8.0 20120825 reported this problem:

    dir.c: In function 'find_dir_file_pathname':
    dir.c:324:54: error: argument 'file' might be clobbered by 'longjmp' or 
'vfork' [-Werror=clobbered]
     find_dir_file_pathname (char const *dir, char const *file)

It seems legit, but perhaps it should be complaining about "match"
rather than "file".

Here's the fix:

>From 6926b608b1a73d35c3caac1253eb985d64ebe545 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 28 Aug 2012 09:39:53 +0200
Subject: [PATCH] diff: avoid possible longjmp-triggered misbehavior

* src/dir.c (find_dir_file_pathname): gcc 4.8.0 20120825 reported
that a local variable's value might be clobbered.  Declare "match"
to point to volatile storage.
 src/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/dir.c b/src/dir.c
index 57134c7..a2f6bba 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -324,7 +324,7 @@ char *
 find_dir_file_pathname (char const *dir, char const *file)
   char *val;
-  char const *match = file;
+  char const *volatile match = file;
   struct dirdata dirdata;
   dirdata.names = NULL;
   dirdata.data = NULL;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]