title: Why do I have a null pointer dereference in C++?
body: <p>I am getting a null pointer dereference in Eclipse and I don't know how to acctually fix this bug.</p>
  
  <p>Here is the log error:</p>
  
  <pre><code>04-18 10:27:48.538: A/DEBUG(22481): Build fingerprint: 
  'OnePlus/OnePlus3/OnePlus3T:8.0.0/OPR6.170623.013/12041042:user/release- keys'
  04-18 10:27:48.538: A/DEBUG(22481): Revision: '0'
  04-18 10:27:48.538: A/DEBUG(22481): ABI: 'arm'
  04-18 10:27:48.538: A/DEBUG(22481): pid: 22024, tid: 22078, name: GLThread     8317  &gt;&gt;&gt;  &lt;&lt;&lt;
  04-18 10:27:48.538: A/DEBUG(22481): signal 11 (SIGSEGV), code 1     (SEGV_MAPERR), fault addr 0x0
  04-18 10:27:48.538: A/DEBUG(22481): Cause: null pointer dereference
  04-18 10:27:48.538: A/DEBUG(22481):     r0 b9bb0e74  r1 00000000  r2     00000001  r3 00000000
  04-18 10:27:48.538: A/DEBUG(22481):     r4 000aa185  r5 afdd0c28  r6     b9bb1a40  r7 b9b83a40
  04-18 10:27:48.538: A/DEBUG(22481):     r8 0000cf00  r9 000ac440  sl     00000000  fp 0000ac44
  04-18 10:27:48.538: A/DEBUG(22481):     ip 000bdcc0  sp c1bfe1b0  lr     c25fd079  pc c25fd084  cpsr 08070030
  04-18 10:27:48.541: A/DEBUG(22481): backtrace:
  04-18 10:27:48.541: A/DEBUG(22481):     #00 pc 0022d084      /data/app/com.-xBYgyq_62u2R3qWK0qBgkQ==/lib/arm/libgame.so     (_ZN12CSoundSource12GetAudioDataEPfii+87)
  </code></pre>
  
  <p>And the error is occuring in this part of the code:</p>
  
  <pre><code>void CSoundSource::GetAudioData(float *data, int frameStart, int frames)
  {
  int i=0;
  while(i&lt;frames)
      {
      int temp_samp = (frameStart+i) % TotalSamples;
      int tmp_div = temp_samp / blockSize;
      int tmp_mod = temp_samp % blockSize;
          *data = block[tmp_div]-&gt;buffer[tmp_mod][0] * 0.00003f;
      data++;
          *data = block[tmp_div]-&gt;buffer[tmp_mod][1] * 0.00003f;
      data++;
      i++;
      }
  }
  </code></pre>
  
  <p>Could someone tell me how to fix the null dereferencing? Or give a hint to point me in the right direction?</p>
  
  <p>Thank you.</p>