|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-02-24 11:32 UTC] derick@php.net
[2004-02-24 17:04 UTC] sniper@php.net
[2004-03-08 07:11 UTC] sniper@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 08:00:01 2025 UTC |
Description: ------------ If I have a function that has a do..while(); construction in it, inside a block container { }, PHP will segfault on exiting the block container UNLESS I have a statement in between the end of the while (); and the closing brace of the block. This does NOT happen in "global" execution. A do..while() loop that lives outside any function's scope works just fine; I have several other do..while() constructs outside of functions that work with no problems. The segfault seems to only happen when the do..while(); is inside a function AND inside a block container (in this case, belonging to an if statement). Any ideas? Reproduce code: --------------- function announce() { global $totalRows_announce, $row_announce, $announce, $srs; $ann = ""; if ($totalRows_announce > 0) { do { $author = mysql_result(mysql_query("SELECT nick FROM players WHERE id='".$row_announce['author']."'", $srs), 0, "nick") or die(mysql_error()); $msg_body = stripslashes(implode("<br>",explode("\n",$row_announce['msg_body']))); $ann .= textBlock(textBlock($row_announce['subject'], "", "anntitle") . br() . textBlock("Posted by:".$author." | On: ".$row_announce['posted_date'], "", "annhead") . br() . textBlock($msg_body, "", "annbody"), "", (($row_announce['urgent'] == 1) ? "redrow" : ((($ctr++) % 2) ? "lightrow" : "darkrow"))) . br(); } while ($row_announce = mysql_fetch_assoc($announce)); // Segfault happens HERE } else { $ann = textBlock("No Announcements", "", "loginerr"); } return $ann; } Expected result: ---------------- The code, as intended, returns a string of HTML code to the calling function. Actual result: -------------- The code immediately segfaults when it encounters the closing brace of the do..while() loop's block container UNLESS there is an intervening statement.