From 2d427bf82e06df106439bbc1add1b8dcfbc84b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 26 Dec 2013 14:51:17 +0100 Subject: Eina_Graph: add vertex arg check and error msg --- src/lib/eina_graph.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 ) -- cgit v1.1-2-g2b99