I want to report the error/bug shown below but I'm not sure whether it is related to Firefox or Slackware. I tried using a new Firefox build from Mozilla with a new profile and yet Firefox crashes. Here is the error line:
Code:
*** glibc detected *** malloc(): memory corruption: 0x0a271520 ***
Here is the steps to reproduce it(Slackware 11.0, Firefox 2.0.0.1 and Firebug 1.0.1):
1. save the following code as myOwnJavascript.html
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript" src="myOwnJavaScript.js"
</head>
<body>
<form id="addressForm">
<label for="dest">Shipping Destination:</label>
<select id="dest">
<option>Boston</option>
<option>Seoul</option>
</select>
<br /><br />
<label for="type">Shipping Type:</label>
<select id="type">
<option>Express Delivery</option>
<option>Standard Delivery</option>
</select>
<br /><br />
<label for="name">Receiver's name:</label>
<input type="text" id="name" value="" />
<br /><br />
<label for="email">Receiver's email address:</label>
<input type="text" id="email" value="" />
<br /><br />
<input type="submit" value="Confirm Address" onclick="return validateForm(this.form)" />
</form>
<div id="myOwndivElement"></div>
</body>
</html>
2. save the following code as myOwnJavascript.js
Code:
function ShippingInfo(dest, type, name, email){
this.DestinationAddress = dest;
this.ShippingType = type;
this.ReceiverName = name;
this.ReceiverEmail = email;
GetShippingCost = GetCost;
}
function GetCost(){
if(DestinationAddress == "Boston" && ShippingType == "Standard Delivery")
return 100;
if(DestinationAddress == "Boston" && ShippingType == "Express Delivery")
return 200;
if(DestinationAddress == "Seoul" && ShippingType == "Standard Delivery")
return 500;
if(DestinationAddress == "Seoul" && ShippingType == "Express Delivery")
return 1000;
}
function prepareForms(){
for(var i = 0; i < document.forms.length; i++){
var thisform = document.forms[i];
thisform.onsubmit = function(){
return validateForm(this);
}
}
}
function validateForm(form){
var valid = true;
var dest = form["dest"];
if(!isFilled(dest)){
alert("Please select a shipping destination.");
valid = false;
}
var type = form["type"];
if(!isFilled(type)){
alert("Please select a shipping type.");
valid = false;
}
var name = form["name"]
if(!isValidName(name)){
alert("The name has to start with 'Receiver'");
valid = false;
}
var email = form["email"];
if(!isEmail(email)){
alert("Please enter a valid email address.");
valid = false;
}
if(valid){
info = new ShippingInfo(dest.value, type.value, name.value, email.value)
cost = info.GetShippingCost()
div = document.getElementById("myOwndivElement");
txt = document.createTextNode(cost);
div.appendChild(txt)
}
}
function isFilled(field){
if(field.value.length < 1 || field.value == field.defaultValue)
return false;
return true;
}
function isEmail(field){
if(field.value.indexOf("@") == -1 || field.value.indexOf(".") == -1)
return false
return true;
}
function isValidName(field){
if(field.value.indexOf("Receiver") == -1)
return false;
return true;
}
3. Run the myOwnJavascript.html file
4. Tools --> Firebug --> Open Firebug
5. Select the 'Script' tag and place a breakpoint at line 54
6. Enter 'Receiver' for the name and any email address
7. Click the 'Confirm Address' button
8. When stopped at line 54 click F11 to Step Into.
At this point you should get the glibc malloc and firefox should crash.