projects
/
sort-networks.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
93e893f
)
src/sn_stage.c: Check arguments in some of the methods.
author
Florian Forster
<octo@verplant.org>
Wed, 19 May 2010 12:56:32 +0000
(14:56 +0200)
committer
Florian Forster
<octo@verplant.org>
Wed, 19 May 2010 12:56:32 +0000
(14:56 +0200)
src/sn_stage.c
patch
|
blob
|
history
diff --git
a/src/sn_stage.c
b/src/sn_stage.c
index
e6425bf
..
7319094
100644
(file)
--- a/
src/sn_stage.c
+++ b/
src/sn_stage.c
@@
-287,6
+287,9
@@
int sn_stage_invert (sn_stage_t *s)
{
int i;
+ if (s == NULL)
+ return (EINVAL);
+
for (i = 0; i < s->comparators_num; i++)
sn_comparator_invert (s->comparators + i);
@@
-297,6
+300,13
@@
int sn_stage_shift (sn_stage_t *s, int sw, int inputs_num)
{
int i;
+ if ((s == NULL) || (inputs_num < 2))
+ return (EINVAL);
+
+ sw %= inputs_num;
+ if (sw == 0)
+ return (0);
+
for (i = 0; i < s->comparators_num; i++)
sn_comparator_shift (s->comparators + i, sw, inputs_num);
@@
-307,6
+317,9
@@
int sn_stage_swap (sn_stage_t *s, int con0, int con1)
{
int i;
+ if (s == NULL)
+ return (EINVAL);
+
for (i = 0; i < s->comparators_num; i++)
sn_comparator_swap (s->comparators + i, con0, con1);