Perl Module: Avoid forcing scalar value into a pointer. 20120912030512/pspp
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 12 Sep 2012 07:26:21 +0000 (09:26 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 12 Sep 2012 07:26:21 +0000 (09:26 +0200)
The code fragment:  struct dictionary *dict = (void *) SvIV (dict_sv);
is dangerous.  This fix uses the properl Perl XS mechanism to get
the pointer and the scalar associated with the dictionary.

Reviewed-By: Ben Pfaff
perl-module/PSPP.xs

index 834ec401f483900d5cd1cb5bfb5d3e08045e7e4a..a66f4427299361e8aad47cc0e19df2342ccb9fdf 100644 (file)
@@ -568,13 +568,12 @@ MODULE = PSPP             PACKAGE = PSPP::Sysfile
 
 
 struct sysfile_info *
-pxs_create_sysfile (name, dict_ref, opts_hr)
+pxs_create_sysfile (name, dict, opts_hr)
  char *name
- SV *dict_ref
+ struct dictionary *dict;
  SV *opts_hr
 INIT:
- SV *dict_sv = SvRV (dict_ref);
- struct dictionary *dict = (void *) SvIV (dict_sv);
+ SV *dict_sv = ST(1);
  struct sfm_write_options opts;
  if (!SvROK (opts_hr))
   {