home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / perl / 7003 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  2.2 KB

  1. Path: sparky!uunet!ukma!darwin.sura.net!zaphod.mps.ohio-state.edu!usc!news!netlabs!lwall
  2. From: lwall@netlabs.com (Larry Wall)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: Bad free() error???
  5. Message-ID: <1992Nov16.192847.21862@netlabs.com>
  6. Date: 16 Nov 92 19:28:47 GMT
  7. References: <dewey-131192123446@sebastian.centerline.com>
  8. Sender: news@netlabs.com
  9. Organization: NetLabs, Inc.
  10. Lines: 50
  11. Nntp-Posting-Host: scalpel.netlabs.com
  12.  
  13. In article <dewey-131192123446@sebastian.centerline.com> dewey@centerline.com (Devan F. dewey) writes:
  14. : Has anyone ever seen this error:
  15. : Bad free() ignored at newreports.pl line 354, <> line 4.
  16. : The code that it points to is:
  17. :    351  sub             getparam {
  18. :    352          local($paramname, $string, $format, $req) = @_;
  19. :    353
  20. :    354          $input = &getinput($string, $format, $req);
  21. :    355          $parameter = " $paramname=$input";
  22. :    356          return $parameter;
  23. :    357  }
  24. :    358
  25. :    359  sub             getinput {
  26. :    360          local($string, $format, $req) = @_;
  27. :    361
  28. :    362          $nogo = 1;
  29. :    363          while ($nogo) {
  30. :    364                  print "\nEnter $string";
  31. :    365                  print " (Hint: $format)" if $format;
  32. :    366                  print ": ";
  33. :    367                  $input = <>;
  34. :    368                  chop $input;
  35. :    369
  36. :    370                  if ($input eq "" & $req) {
  37. :    371                          print "\n$string may not be empty.\n";
  38. :    372                          $nogo = 1;
  39. :    373                  } else {
  40. :    374                          $nogo = 0;
  41. :    375                  }
  42. :    376          }
  43. :    377
  44. :    378          return $input;
  45. :    379  }
  46. :    380
  47.  
  48. Try putting a local($input) into getinput.  I suspect that the problem
  49. might have to do with returning a variable into itself.  You could also
  50. play with changing "return $input" to simply "$input", since the last
  51. expression is returned by default anyway, and it'd be more efficient.
  52. Other than that, I have no idea.
  53.  
  54. Note in line 370 that you've got a & where you really want &&.  The
  55. single & will work as long as both sides evaluate to 1 or 0, and you
  56. don't care that both sides are always evaluated, but it's a potentially
  57. deleterious habit to get into.
  58.  
  59. Larry
  60.