summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-12-26 14:51:17 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2013-12-26 14:51:17 +0100
commit2d427bf82e06df106439bbc1add1b8dcfbc84b82 (patch)
tree5dc5dddba0dc882730a291420d9ba80cf6ea8cbc /src
parent78cc6d7c071fcc6ff1dc9458443168f4c0fa76ca (diff)
downloadeina_graph-2d427bf82e06df106439bbc1add1b8dcfbc84b82.zip
eina_graph-2d427bf82e06df106439bbc1add1b8dcfbc84b82.tar.gz
Eina_Graph: add vertex arg check and error msg
Diffstat (limited to 'src')
-rw-r--r--src/lib/eina_graph.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/eina_graph.c b/src/lib/eina_graph.c
index 1216efc..9e6569b 100644
--- a/src/lib/eina_graph.c
+++ b/src/lib/eina_graph.c
@@ -85,6 +85,12 @@ eina_graph_degree(const Eina_Graph *g, unsigned int v)
{
_Eina_Graph * _g = (_Eina_Graph *) g;
+ if (v >= _g->vertices)
+ {
+ ERR("%u is out of [0;%u[", v, _g->vertices);
+ return 0;
+ }
+
return _g->adjs[v].count;
}
@@ -138,7 +144,11 @@ eina_graph_edge_add(Eina_Graph *g, unsigned int v, unsigned int w)
{
_Eina_Graph * _g = (_Eina_Graph *) g;
- if ((v >= _g->vertices) || (w >= _g->vertices)) return EINA_FALSE;
+ if ((v >= _g->vertices) || (w >= _g->vertices))
+ {
+ ERR("%u->%u is out of [0;%u[", v, w, _g->vertices);
+ return EINA_FALSE;
+ }
if(!eina_graph_adjacents_push(&_g->adjs[v], w, _g->step)) return EINA_FALSE;
if (v != w )