title: Address Out of bounds error when reading xml
body: <p>I am getting a weird segfault when using libxml to parse a file. This code worked previously when I compiled it as a 32bit application. I changed it to a 64 bit application and it stops working.</p>
  
  <p>The seg fault comes in at "if (xmlStrcmp(cur->name, (const xmlChar *) "servers"))" </p>
  
  <p>cur->name is a const xmlChar * and it points to an address that says its out out bounds. But when I debug and go to that memory location, that data is correct.</p>
  
  <pre><code>int XmlGetServers()
  {
  xmlDocPtr doc;
  xmlNodePtr cur;
  
  doc = xmlParseFile("Pin.xml");
  if (doc == NULL)
  {
      std::cout &lt;&lt; "\n Pin.xml not parsed successfully." &lt;&lt; std::endl;
      return -1;
  }
  cur = xmlDocGetRootElement(doc);
  
  if (cur == NULL)
  {
      std::cout &lt;&lt; "\n Pin.xml is empty document." &lt;&lt; std::endl;
      xmlFreeDoc(doc);
      return -1;
  }
  if (xmlStrcmp(cur-&gt;name, (const xmlChar *) "servers"))
  {
      std::cout &lt;&lt; "\n ERROR: Pin.xml of the wrong type, root node != servers." &lt;&lt; std::endl;
      xmlFreeDoc(doc);
      return -1;
  }
  }
  </code></pre>
  
  <p>Before cur is initialized the name parameter is</p>
  
  <pre><code>Name : name
      Details:0xed11f72000007fff &lt;Address 0xed11f72000007fff out of bounds&gt;
  </code></pre>
  
  <p>After cur is initialized the name parameter is</p>
  
  <pre><code>Name : name
      Details:0x64c43000000000 &lt;Address 0x64c43000000000 out of bounds&gt; 
  </code></pre>
  
  <p>Referenced XML file</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  
  &lt;servers&gt;
  
  &lt;server_info&gt;
  
      &lt;server_name&gt;Server1&lt;/server_name&gt;
  
      &lt;server_ip&gt;127.0.0.1&lt;/server_ip&gt; 
  
      &lt;server_data_port&gt;9000&lt;/server_data_port&gt; 
  
  &lt;/server_info&gt;
  
  &lt;server_info&gt;
  
      &lt;server_name&gt;Server2&lt;/server_name&gt; 
  
      &lt;server_ip&gt;127.0.0.1&lt;/server_ip&gt; 
  
      &lt;server_data_port&gt;9001&lt;/server_data_port&gt; 
  
  &lt;/server_info&gt;
  
  &lt;/servers&gt;
  </code></pre>
  
  <p>System:</p>
  
  <p>OS: Redhat Enterprise Linux 6.4 64-bit</p>
  
  <p>GCC: 4.4.7-3</p>
  
  <p>packages: libxml2-2.7.6-8.el6_3.4.x86_64</p>