Blame SOURCES/0039-perl-Give-error-instead-of-crashing-if-optarg-is-not.patch

cd6068
From 87b8584d6acc50751dffd81d8bb187d3ad73462c Mon Sep 17 00:00:00 2001
cd6068
From: "Richard W.M. Jones" <rjones@redhat.com>
cd6068
Date: Thu, 14 Nov 2013 15:45:23 +0000
cd6068
Subject: [PATCH] perl: Give error instead of crashing if optarg is not an
cd6068
 array reference.
cd6068
cd6068
  $g->add_drive ("", server => 1);
cd6068
cd6068
would segfault.  Now it gives a nice error instead:
cd6068
cd6068
  array reference expected for 'server' argument at [line]
cd6068
cd6068
(cherry picked from commit c032130226bdca539b8ac34ce622e5cd9a71c152)
cd6068
---
cd6068
 generator/perl.ml | 5 ++++-
cd6068
 1 file changed, 4 insertions(+), 1 deletion(-)
cd6068
cd6068
diff --git a/generator/perl.ml b/generator/perl.ml
cd6068
index 1acd782..9b7c25a 100644
cd6068
--- a/generator/perl.ml
cd6068
+++ b/generator/perl.ml
cd6068
@@ -464,10 +464,13 @@ PREINIT:
cd6068
              | OStringList _ ->
cd6068
                pr "          size_t i, len;\n";
cd6068
                pr "          char **r;\n";
cd6068
+               pr "          SV *arg;\n";
cd6068
                pr "          AV *av;\n";
cd6068
                pr "          SV **svp;\n";
cd6068
                pr "\n";
cd6068
-               pr "          /* XXX More checking required here. */\n";
cd6068
+               pr "          arg = ST (items_i+1);\n";
cd6068
+               pr "          if (!SvROK (arg) || SvTYPE (SvRV (arg)) != SVt_PVAV)\n";
cd6068
+               pr "            croak (\"array reference expected for '%%s' argument\", \"%s\");\n" n;
cd6068
                pr "          av = (AV *) SvRV (ST (items_i+1));\n";
cd6068
                pr "\n";
cd6068
                pr "          /* Note av_len returns index of final element. */\n";
cd6068
-- 
cd6068
1.8.3.1
cd6068