File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 24
24
25
25
#include "rinterface.h"
26
26
27
+ // This is a variant of IGRAPH_FINALLY that satisfies UBSAN checks.
28
+ #define IGRAPH_FINALLY_PV (func , ptr ) \
29
+ do { \
30
+ /* the following branch makes the compiler check the compatibility of \
31
+ * func and ptr to detect cases when we are accidentally invoking an \
32
+ * incorrect destructor function with the pointer */ \
33
+ if (0) { func(ptr); } \
34
+ IGRAPH_FINALLY_REAL((igraph_finally_func_t*)(func##_pv), (ptr)); \
35
+ } while (0)
36
+
37
+ void igraph_vector_int_destroy_pv (void * pv_ptr ) {
38
+ igraph_vector_int_destroy ((igraph_vector_int_t * ) pv_ptr );
39
+ }
40
+
27
41
/***********************************************/
28
42
/* THE REST IS GENERATED BY stimulus */
29
43
/***********************************************/
@@ -11272,7 +11286,7 @@ SEXP R_igraph_eulerian_cycle(SEXP graph) {
11272
11286
if (0 != igraph_vector_int_init (& c_vertex_res , 0 )) {
11273
11287
igraph_error ("" , __FILE__ , __LINE__ , IGRAPH_ENOMEM );
11274
11288
}
11275
- IGRAPH_FINALLY (igraph_vector_int_destroy , & c_vertex_res );
11289
+ IGRAPH_FINALLY_PV (igraph_vector_int_destroy , & c_vertex_res );
11276
11290
/* Call igraph */
11277
11291
IGRAPH_R_CHECK (igraph_eulerian_cycle (& c_graph , & c_edge_res , & c_vertex_res ));
11278
11292
You can’t perform that action at this time.
0 commit comments