title: EXC_BAD_ACCESS when assigning an Objective-C pointer to a member of a C struct
body: <p>Sometimes but not always I'm getting an <code>EXC_BAD_ACCESS</code> crash assigning an <code>NSMutableDictionary</code> to a struct. I'm obviously doing something wrong but I have no idea what.</p>
  <pre><code>typedef struct {
      
      ...
      NSMutableDictionary* headers;
      ...
      
  } custom_data_t;
  
  ...
  
  - (void)method {
  
      custom_data_t* customData = malloc(sizeof(custom_data_t));
      customData-&gt;headers = [NSMutableDictionary new]; // &lt;- EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
  
  }
  </code></pre>