title: Heap block at X modified at Y past requested size - freeing allocated memory
body: <p>Program crashing when freeing allocated memory: "Heap block at X modified at Y past requested size of 21".</p>
  
  <p>Running function getUstr, crashes on free(uStr).
  Can someone please help me find where am I using unallocated memory?
  Thank you!</p>
  
  <pre><code>int HexToUChars(char* hexStr, unsigned char **str){
      int i, n;
      int strLen = strlen(hexStr)/2;
  
      for (i = 0; i &lt; (int)strLen; i++) {
  
          sscanf_s(hexStr + 2 * i*sizeof(unsigned char), "%02X", *str+i*sizeof(unsigned char));
      }
  
      return 0;
  }
  
  int getUStr(){
      char *hexStr = "E7CA7905DD060F0E437C885BF13DED9243B1D2BD94CB11223DA71360A8F7D2D4";
      unsigned char *uStr;
      size_t strLen = (size_t)strlen(hexStr) / 2;
      uStr = calloc((strLen + 1), sizeof(unsigned char));
      if (uStr != NULL){
          HexToUChars(hexStr, &amp;uStr);
          free(uStr);//Error : Heap block at X modified at Y past requested size of 21
      }
  }
  </code></pre>