diff options
Diffstat (limited to 'src/bencoding.c')
-rw-r--r-- | src/bencoding.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/bencoding.c b/src/bencoding.c index 6e8a2a2..991ac9c 100644 --- a/src/bencoding.c +++ b/src/bencoding.c @@ -453,13 +453,17 @@ struct bencoding * bdecode_safe (const char * s, int len, enum benc opts, unsign b->intvalue = strtol(s+1, &ch, 10); b->valuelen = ch-(s+1); b->value = malloc(b->valuelen+1); - if (!b->value) + if (!b->value) { + free(b); return NULL; + } strncpy(b->value, s+1, b->valuelen); b->value[b->valuelen] = '\0'; b->after = s+2+b->valuelen; - } else + } else { + free(b); return NULL; + } break; case 'd': /* dict */ b->type = dict; |