title: Why my program crashes after second usage of a string in different functions?
body: <p>When I run my program , it calls a function that have a "char *msgtype" and this function work probably but when another function use a different "char *msgtype" in it when program reach the line that contain it , program crashes(and even when the firs function is called for second time program crashes). What is the problem ?</p>
  
  <p>and if I change the name in the second function it just work one time and after calling that function again program crashes !</p>
  
  <pre><code>void fun1(){
      ...
  
      cJSON *root = cJSON_Parse(buffer);
      char *msgtype = cJSON_GetObjectItem(root,"type")-&gt;valuestring;
  
      ...
  
      free(msgtype);
      cJSON_Delete(root);
  
      ...
  }
  
  void fun2(){
      ...
  
      cJSON *root = cJSON_Parse(buffer);
      char *msgtype = cJSON_GetObjectItem(root,"type")-&gt;valuestring;//it crashes here
  
      ...
  
      free(msgtype);
      cJSON_Delete(root);
  
      ...
  }
  
  int main(){
      fun1();
      fun2();//it crashes inside this function !
  }
  </code></pre>