home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ukma!darwin.sura.net!zaphod.mps.ohio-state.edu!usc!news!netlabs!lwall
- From: lwall@netlabs.com (Larry Wall)
- Newsgroups: comp.lang.perl
- Subject: Re: Bad free() error???
- Message-ID: <1992Nov16.192847.21862@netlabs.com>
- Date: 16 Nov 92 19:28:47 GMT
- References: <dewey-131192123446@sebastian.centerline.com>
- Sender: news@netlabs.com
- Organization: NetLabs, Inc.
- Lines: 50
- Nntp-Posting-Host: scalpel.netlabs.com
-
- In article <dewey-131192123446@sebastian.centerline.com> dewey@centerline.com (Devan F. dewey) writes:
- : Has anyone ever seen this error:
- :
- : Bad free() ignored at newreports.pl line 354, <> line 4.
- :
- : The code that it points to is:
- :
- : 351 sub getparam {
- : 352 local($paramname, $string, $format, $req) = @_;
- : 353
- : 354 $input = &getinput($string, $format, $req);
- : 355 $parameter = " $paramname=$input";
- : 356 return $parameter;
- : 357 }
- : 358
- : 359 sub getinput {
- : 360 local($string, $format, $req) = @_;
- : 361
- : 362 $nogo = 1;
- : 363 while ($nogo) {
- : 364 print "\nEnter $string";
- : 365 print " (Hint: $format)" if $format;
- : 366 print ": ";
- : 367 $input = <>;
- : 368 chop $input;
- : 369
- : 370 if ($input eq "" & $req) {
- : 371 print "\n$string may not be empty.\n";
- : 372 $nogo = 1;
- : 373 } else {
- : 374 $nogo = 0;
- : 375 }
- : 376 }
- : 377
- : 378 return $input;
- : 379 }
- : 380
-
- Try putting a local($input) into getinput. I suspect that the problem
- might have to do with returning a variable into itself. You could also
- play with changing "return $input" to simply "$input", since the last
- expression is returned by default anyway, and it'd be more efficient.
- Other than that, I have no idea.
-
- Note in line 370 that you've got a & where you really want &&. The
- single & will work as long as both sides evaluate to 1 or 0, and you
- don't care that both sides are always evaluated, but it's a potentially
- deleterious habit to get into.
-
- Larry
-