Skip to content

Commit

Permalink
Type check before obtaining a data pointer.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@87543 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
kalibera committed Jan 8, 2025
1 parent 15294dd commit 954a267
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/library/stats/src/family.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
* Copyright (C) 2005-2022 The R Core Team
* Copyright (C) 2005-2025 The R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -59,11 +59,11 @@ static R_INLINE double x_d_opx(double x) {return x/(1 + x);}
SEXP logit_link(SEXP mu)
{
int i, n = LENGTH(mu);
if (!n || !isReal(mu))
error(_("Argument %s must be a nonempty numeric vector"), "mu");
SEXP ans = PROTECT(shallow_duplicate(mu));
double *rans = REAL(ans), *rmu=REAL(mu);

if (!n || !isReal(mu))
error(_("Argument %s must be a nonempty numeric vector"), "mu");
for (i = 0; i < n; i++)
rans[i] = log(x_d_omx(rmu[i]));
UNPROTECT(1);
Expand All @@ -72,12 +72,12 @@ SEXP logit_link(SEXP mu)

SEXP logit_linkinv(SEXP eta)
{
SEXP ans = PROTECT(shallow_duplicate(eta));
int i, n = LENGTH(eta);
double *rans = REAL(ans), *reta = REAL(eta);

if (!n || !isReal(eta))
error(_("Argument %s must be a nonempty numeric vector"), "eta");
SEXP ans = PROTECT(shallow_duplicate(eta));
double *rans = REAL(ans), *reta = REAL(eta);

for (i = 0; i < n; i++) {
double etai = reta[i], tmp;
tmp = (etai < MTHRESH) ? DBL_EPSILON :
Expand All @@ -90,12 +90,12 @@ SEXP logit_linkinv(SEXP eta)

SEXP logit_mu_eta(SEXP eta)
{
SEXP ans = PROTECT(shallow_duplicate(eta));
int i, n = LENGTH(eta);
double *rans = REAL(ans), *reta = REAL(eta);

if (!n || !isReal(eta))
error(_("Argument %s must be a nonempty numeric vector"), "eta");
SEXP ans = PROTECT(shallow_duplicate(eta));
double *rans = REAL(ans), *reta = REAL(eta);

for (i = 0; i < n; i++) {
double etai = reta[i];
double opexp = 1 + exp(etai);
Expand Down

0 comments on commit 954a267

Please sign in to comment.