From: Ansgar Burchardt <ansgar@43-1.org>
Date: Thu, 26 Aug 2010 17:08:56 +0900
Origin: vendor
Bug-Debian: https://bugs.debian.org/558272
Bug: https://rt.cpan.org/Ticket/Display.html?id=60233
Subject: Use SvPV to strigify the SV in case it is not already a string

--- libdate-calc-perl.orig/XS.xs
+++ libdate-calc-perl/XS.xs
@@ -51,9 +51,7 @@
 
 
 #define DATECALC_STRING(ref,var,len) \
-    ( ref && !(SvROK(ref)) && SvPOK(ref) && \
-    (var = (charptr)SvPV(ref,PL_na)) && \
-    ((len = (N_int)SvCUR(ref)) | 1) )
+    ( ref && (var = (charptr)SvPV(ref,len)) )
 
 #define DATECALC_SCALAR(ref,typ,var) \
     ( ref && !(SvROK(ref)) && ((var = (typ)SvIV(ref)) | 1) )
@@ -1268,7 +1266,7 @@
 PPCODE:
 {
     charptr string;
-    N_int   length;
+    STRLEN  length;
     Z_int   lang;
 
     if ((items == 1) or (items == 2))
@@ -1295,7 +1293,7 @@
 PPCODE:
 {
     charptr string;
-    N_int   length;
+    STRLEN  length;
     Z_int   lang;
 
     if ((items == 1) or (items == 2))
@@ -1333,7 +1331,7 @@
 PPCODE:
 {
     charptr string;
-    N_int   length;
+    STRLEN  length;
     Z_int   lang;
     Z_int   year;
     Z_int   month;
@@ -1369,7 +1367,7 @@
 PPCODE:
 {
     charptr string;
-    N_int   length;
+    STRLEN  length;
     Z_int   lang;
     Z_int   year;
     Z_int   month;
@@ -1780,8 +1778,8 @@
 {
     charptr string;
     charptr buffer;
-    N_int length;
-    N_int index;
+    STRLEN length;
+    STRLEN index;
 
     if ( DATECALC_STRING(scalar,string,length) )
     {
@@ -1808,8 +1806,8 @@
 {
     charptr string;
     charptr buffer;
-    N_int length;
-    N_int index;
+    STRLEN length;
+    STRLEN index;
 
     if ( DATECALC_STRING(scalar,string,length) )
     {
--- /dev/null
+++ libdate-calc-perl/t/debian-558272.t
@@ -0,0 +1,23 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More 0.88;
+use Test::Exception;
+
+use_ok("Date::Calc");
+
+my $string = "Oct";
+$string =~ /(.*)/;
+lives_and { is Date::Calc::Decode_Month($1), 10 } 'Decode_Month($1) works';
+
+{
+  package
+    Foo;
+  use overload '""' => sub { "Nov" };
+}
+my $foo = bless {}, 'Foo';
+lives_and { is Date::Calc::Decode_Month($foo), 11 } 'Decode_Month() works with overload';
+
+done_testing();
