Skip to content

Commit

Permalink
Zero-terminate string (courtesy of Dave Fernandes)
Browse files Browse the repository at this point in the history
  • Loading branch information
glebd committed May 31, 2012
1 parent f959604 commit 4c7af17
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion objc/NSData+PECrypt.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ - (NSString *)base32 {
if (![self length])
return @"";
size_t bufsize = base32_encoder_buffer_size([self length]);
char *buf = malloc(bufsize);
char *buf = malloc(bufsize+1);
buf[bufsize] = 0;
if (!buf)
return @"";
base32_encode((uint8_t *)buf, bufsize, [self bytes], [self length]);
Expand Down

0 comments on commit 4c7af17

Please sign in to comment.