Package: scamp / 2.0.4+dfsg-1

Fix-segfault-in-load_field-at-field.c-343.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From: "Roy Clark (kralcyor)" <royclark086@gmail.com>
Date: Fri, 1 Dec 2017 14:32:40 +0800
Subject: Fix segfault in load_field() at field.c:343

When build the package with gcc option -Wsequence-point enabled(add
"export DEB_CFLAGS_MAINT_APPEND = -Wsequence-point" to debian/rules),
there is the following warning:

gcc -DHAVE_CONFIG_H -I. -I..  -I/usr/include/plplot -Wdate-time -D_FORTIFY_SOURCE=2 -D_REENTRANT -g -O2 -fdebug-prefix-map=/home/kralcyor/tmp/packaging/scamp/scamp-2.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wsequence-point -c -o field.o field.c
field.c: In function 'load_field':
field.c:343:27: warning: operation on 'n' may be undefined [-Wsequence-point]
       set[n]->setindex = n++;
                          ~^~

Closes: #883236
---
 src/field.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/field.c b/src/field.c
index a8a016d..d958393 100644
--- a/src/field.c
+++ b/src/field.c
@@ -340,7 +340,8 @@ fieldstruct	*load_field(char *filename, int fieldindex)
       nsample += set[n]->nsample;
       free_tab(set[n]->imatab);
       set[n]->imatab = NULL;
-      set[n]->setindex = n++;
+      set[n]->setindex = n;
+      n++;
       }
 
   field->nsample = nsample;