title: Call to malloc() causes unexplicable program crash
body: <p>I'm having an issue where a call I'm making to <code>malloc()</code> causes my program to crash. Here's the code:</p>
  
  <pre><code>void update_item(char *input, item_t *new_node){
      int i, count, shelf, weight, price, quantity;
      char *name;
      char *specifier;
      char aisle[1];
      count = 0;
  
      /*Find name of the new item and assign to the name field of    new_node...*/
      for (i = 0; input[i] != ','; i++){
          count++;
      }
      name = (char*)malloc((count+1)*sizeof(char));
      if (name == NULL){
          printf("Out of memory. Shutting down.\n");
          exit(EXIT_FAILURE);
      }
      for (i = 0; input[i] != ','; i++){
          name[i] = input[i];
      }
      name[count+1] = '\0';
      new_node-&gt;name = name;
      printf("%s\n", new_node-&gt;name);
  
      /*Find aisle specifier and assign it to aisle field of new_node...*/
      i++;
      aisle[0] = input[i];
      aisle[1] = '\0';
      new_node-&gt;aisle = aisle;
      printf("%s\n", new_node-&gt;aisle);
  
      for(i = i+2, count = 0; input[i] != ','; i++){
          count++;
      }
      specifier = (char*)malloc(count*sizeof(char)); /*PROGRAM CRASHES HERE*/
      if (specifier == NULL){
          printf("Out of memory. Shutting down.\n");
          exit(EXIT_FAILURE);
      }
      printf("boom\n");
  </code></pre>
  
  <p>I'm utterly stumped. There's two identical calls to <code>malloc()</code> but for some reason the second fails every single time while the first one always is a success.</p>