title: Address boundary error
body: <p>UPD2:
  The algoritm generates bytes out of allocated range. So it's a logical mistake.</p>
  
  <p>UPD:
  modifyed printf to</p>
  
  <pre><code>printf("%d\n", bytes);
  </code></pre>
  
  <p>But the result is same - SIGSEGV.</p>
  
  <p>I am new in pure c coding. This is simple near "hello world" app:</p>
  
  <pre><code>#include &lt;stdint.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdbool.h&gt;
  
  
  void encode2(int src){
      unsigned char * result =(unsigned char *) malloc(sizeof(unsigned char) *10);
      int bytes = 0;
      bool More;
      do{
          uint8_t Byte = src &amp; 0x7f;
          src &gt;&gt; 7;
          More = !((((src == 0) &amp;&amp; ((Byte &amp; 0x40) == 0)) ||
                    ((src == -1) &amp;&amp; ((Byte &amp; 0x40) != 0))));
          if (More)
              Byte |= 0x80;
          result[bytes] = Byte;
          bytes++;
      } while(More);
      printf(bytes);
      unsigned char * str = (unsigned char *) malloc(sizeof(unsigned char) * bytes);
      int i;
      for (i=0; i&lt;bytes; i++){
          str[i] = result[i];
      }
  }
  
  int main(int argc, char *argv[]){
      encode2(10);
      /*printf("%s\n",p);*/
      return 0;
  }
  </code></pre>
  
  <blockquote>
    <p>Job 1, './leb128' terminated by signal SIGSEGV (Address boundary error)</p>
  </blockquote>
  
  <p>Tried to google SIGSEGV but couldn't found whats wrong?</p>