Bug #8500

date_core testing address not value of variable on stack

Added by teleological (Riley Lynch) almost 5 years ago. Updated almost 5 years ago.

Target version:
ruby -v:
ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-darwin12.3.0]


This line appears ten times in date_core.c:

decode_year(y, ns ? -1 : +1, &nth2, ry);

The type of ns is int*, and it seems to always be populated with the address of a stack variable, with the effect that the condition is always true. It looks like the intent is to ensure that decode_year uses Gregorian years if the value ns is true, i.e.:

decode_year(y, *ns ? -1 : +1, &nth2, ry);

It may be the case that this code is unreachable: guess_style() would have to return zero and nth would have to be calculated to be greater or less than zero. Is there any way that could happen?

email.patch (2.5 KB) email.patch teleological (Riley Lynch), 06/06/2013 05:09 PM

Related issues

Related to Backport200 - Backport #8578: r41077, r41105Closed2013-06-29

Associated revisions

Revision e931e27a
Added by nagachika (Tomoyuki Chikanaga) almost 5 years ago

merge revision(s) 41077,41105: [Backport #8485] [Backport #8500] [Backport #8578]

* ext/date/date_core.c: fixed a bug .  reported
  by Riley Lynch.

* ext/date/date_core.c: fixed coding error .
  reported by Riley Lynch.

git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e


#1 [ruby-core:55340] Updated by tadf (tadayoshi funaba) almost 5 years ago

  • Status changed from Open to Closed
  • Priority changed from Normal to 3

coding error;
but, it seems to lack effects.

Also available in: Atom PDF