From dfcd262aa5ca535e8542df897829ecb79dd4d412 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Thu, 23 Jul 2026 12:54:30 -0700 Subject: [PATCH 1/2] Always initialize c_options=NULL --- src/rinterface.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rinterface.c b/src/rinterface.c index d6c93c93b63..1ff2711494b 100644 --- a/src/rinterface.c +++ b/src/rinterface.c @@ -5323,7 +5323,7 @@ SEXP R_igraph_pagerank(SEXP graph, SEXP algo, SEXP vids, SEXP directed, SEXP dam igraph_real_t c_damping; igraph_vector_t c_weights; igraph_arpack_options_t c_options1; - void* c_options; + void* c_options = NULL; SEXP vector; SEXP value; @@ -5396,7 +5396,7 @@ SEXP R_igraph_personalized_pagerank(SEXP graph, SEXP algo, SEXP vids, SEXP direc igraph_vector_t c_personalized; igraph_vector_t c_weights; igraph_arpack_options_t c_options1; - void* c_options; + void* c_options = NULL; SEXP vector; SEXP value; @@ -5472,7 +5472,7 @@ SEXP R_igraph_personalized_pagerank_vs(SEXP graph, SEXP algo, SEXP vids, SEXP di igraph_vs_t c_reset_vids; igraph_vector_t c_weights; igraph_arpack_options_t c_options1; - void* c_options; + void* c_options = NULL; SEXP vector; SEXP value; From a5a4a53c40dd049bd543a429f6ef4d7c5678f668 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 27 Jul 2026 04:31:56 +0000 Subject: [PATCH 2/2] fix: initialize `c_options` in the Stimulus type definition The `PAGERANKOPT` type declares an optional `INOUT` argument, so Stimulus wraps its input conversion into `if (!Rf_isNull(options))`, but passes the pointer to `igraph_pagerank()` unconditionally. Reading it when `options` is `NULL` at the R level is an uninitialized read, flagged by `clang -Wsometimes-uninitialized`. Declare the pointer with a `NULL` initializer via `CDECL`, which is the same fix as in #2751 but applied to the code generator. The `else` branch of the input conversion becomes redundant and is dropped, so the default lives in one place only. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01RF5eavxtBTfTSquRjc2San --- src/rinterface.c | 6 ------ tools/stimulus/types-RC.yaml | 12 ++++++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/rinterface.c b/src/rinterface.c index 1ff2711494b..f74588cd392 100644 --- a/src/rinterface.c +++ b/src/rinterface.c @@ -5346,8 +5346,6 @@ SEXP R_igraph_pagerank(SEXP graph, SEXP algo, SEXP vids, SEXP directed, SEXP dam if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { Rz_SEXP_to_igraph_arpack_options(options, &c_options1); c_options = &c_options1; - } else { - c_options = NULL; } } /* Call igraph */ @@ -5422,8 +5420,6 @@ SEXP R_igraph_personalized_pagerank(SEXP graph, SEXP algo, SEXP vids, SEXP direc if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { Rz_SEXP_to_igraph_arpack_options(options, &c_options1); c_options = &c_options1; - } else { - c_options = NULL; } } /* Call igraph */ @@ -5497,8 +5493,6 @@ SEXP R_igraph_personalized_pagerank_vs(SEXP graph, SEXP algo, SEXP vids, SEXP di if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { Rz_SEXP_to_igraph_arpack_options(options, &c_options1); c_options = &c_options1; - } else { - c_options = NULL; } } /* Call igraph */ diff --git a/tools/stimulus/types-RC.yaml b/tools/stimulus/types-RC.yaml index 7c362dba585..3d1ada36ec9 100644 --- a/tools/stimulus/types-RC.yaml +++ b/tools/stimulus/types-RC.yaml @@ -995,16 +995,20 @@ SIR_LIST: IGRAPH_FINALLY_CLEAN(1); PAGERANKOPT: - CTYPE: |- + CTYPE: void* + # The argument is optional, + # so the code generator wraps the input conversion into `if (!Rf_isNull(...))`. + # The pointer is passed on to igraph unconditionally, + # therefore it must be initialized here + # to stay well-defined on the path where the conversion is skipped. + CDECL: |- igraph_arpack_options_t %C%1; - void* + void* %C% = NULL; INCONV: INOUT: |- if (%C1% == IGRAPH_PAGERANK_ALGO_ARPACK) { Rz_SEXP_to_igraph_arpack_options(%I%, &%C%1); %C% = &%C%1; - } else { - %C% = NULL; } OUTCONV: INOUT: |-