[Rd] print.matrix segfaults if rowlab vector too short (PR#850)

Thomas Lumley tlumley@u.washington.edu
Fri, 16 Feb 2001 08:50:01 -0800 (PST)


On Fri, 16 Feb 2001 pdenis2@home.com wrote:

> print.matrix(x) segfaults if the vector supplied to 'rowlab' is
> *shorter* than nrow(x):
>

Ok, the cause is the obvious one: there is no check for the length of
rowlab in print[type]Matrix, nor in formatString. formatString happily
wanders along the vector and falls off the end.

I'm going to fix it in formatString, we may also want to fix it higher up.

	-thomas


> > version
>          _
> platform i686-pc-linux-gnu
> arch     i686
> os       linux-gnu
> system   i686, linux-gnu
> status
> major    1
> minor    2.1
> year     2001
> month    01
> day      15
> language R
> [installed from RPM]
>
> > x<-1:4
> > dim(x)<-c(2,2)
> > x
>      [,1] [,2]
> [1,]    1    3
> [2,]    2    4
> > print.matrix(x)
>      [,1] [,2]
> [1,]    1    3
> [2,]    2    4
> > print.matrix(x,rowlab=c('a','b'))
>   [,1] [,2]
> a    1    3
> b    2    4
> > print.matrix(x,rowlab=c('a','b','c'))
>   [,1] [,2]
> a    1    3
> b    2    4                                             [OK, ignores
> extra labels ...]
> > print.matrix(x,rowlab=c('a'))
> Segmentation fault (core dumped)
>
> Similar behavior for 'collab' ...
>
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

Thomas Lumley			Asst. Professor, Biostatistics
tlumley@u.washington.edu	University of Washington, Seattle
^^^^^^^^^^^^^^^^^^^^^^^^
 NOTE NEW EMAIL ADDRESS

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._