diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2013-12-26 14:51:17 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2013-12-26 14:51:17 +0100 |
commit | 2d427bf82e06df106439bbc1add1b8dcfbc84b82 (patch) | |
tree | 5dc5dddba0dc882730a291420d9ba80cf6ea8cbc | |
parent | 78cc6d7c071fcc6ff1dc9458443168f4c0fa76ca (diff) | |
download | eina_graph-2d427bf82e06df106439bbc1add1b8dcfbc84b82.zip eina_graph-2d427bf82e06df106439bbc1add1b8dcfbc84b82.tar.gz |
Eina_Graph: add vertex arg check and error msg
-rw-r--r-- | src/lib/eina_graph.c | 12 |
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 ) |