title: Bad permissions for mapped region
body: <p>I get an error when trying to run the following function:</p>
  
  <pre><code>   char* reverseInPlace(char* src)
  {
      //no need to alloc or free memory
      int i=0;
      int size=mystrlen(src);
      for(i=0;i&lt;size;i++)
      {
          int j=size-i-1;
  
          if(i&lt;j)
          {
              char temp;
              printf("Interchange start %d:%c with %d:%c",i,src[i],j,src[j]);
              temp=src[i];
              src[i]=src[j];//error occurs here
              src[j]=temp;
              printf("Interchange complete %d:%c and %d:%c",i,src[i],j,src[j]);
          }   
      }
      return src; 
  }
  </code></pre>
  
  <p>I call this code like this:</p>
  
  <pre><code>char* rev2=reverseInPlace("BeforeSunrise");
  printf("The reversed string is %s\n",rev2);
  </code></pre>
  
  <p>The error looks like this:</p>
  
  <pre><code>Interchange start 0:B with 12:e
  Process terminating with default action of signal 11 (SIGSEGV)
  Bad permissions for mapped region at address 0x401165
  </code></pre>
  
  <p>Why does this error occur?  </p>