fix some resulting segfaults

git.mgm/mediaproxy-ng/2.2
Richard Fuchs 12 years ago
parent 1160c5c0ad
commit ea16a5daa2

@ -84,6 +84,7 @@ int bencode_buffer_init(bencode_buffer_t *buf) {
buf->pieces = __bencode_piece_new(0);
if (!buf->pieces)
return -1;
buf->free_list = NULL;
return 0;
}

@ -97,10 +97,9 @@ static inline bencode_item_t *bencode_dictionary_add_string(bencode_item_t *dict
/* Ditto, but for a "str" object */
static inline bencode_item_t *bencode_dictionary_add_str(bencode_item_t *dict, const char *key, const str *val);
/* Ditto again, but adds the buffer which contains the string (val->s) to the bencode_buffer_t's
* internal free list. When the bencode_item_t object is destroyed, BENCODE_FREE will be called
* on this buffer. */
static inline bencode_item_t *bencode_dictionary_add_str_free(bencode_item_t *dict, const char *key, const str *val);
/* Ditto again, but adds the str object (val) to the bencode_buffer_t's internal free list. When
* the bencode_item_t object is destroyed, BENCODE_FREE will be called on this pointer. */
static inline bencode_item_t *bencode_dictionary_add_str_free(bencode_item_t *dict, const char *key, str *val);
/* Convenience function to add an integer value to a dictionary */
static inline bencode_item_t *bencode_dictionary_add_integer(bencode_item_t *dict, const char *key, long long int val);
@ -275,10 +274,10 @@ static inline bencode_item_t *bencode_dictionary_add_str(bencode_item_t *dict, c
return bencode_dictionary_add(dict, key, bencode_str(dict->buffer, val));
}
static inline bencode_item_t *bencode_dictionary_add_str_free(bencode_item_t *dict, const char *key, const str *val) {
static inline bencode_item_t *bencode_dictionary_add_str_free(bencode_item_t *dict, const char *key, str *val) {
if (!val)
return NULL;
bencode_buffer_freelist_add(dict->buffer, val->s);
bencode_buffer_freelist_add(dict->buffer, val);
return bencode_dictionary_add(dict, key, bencode_str(dict->buffer, val));
}

Loading…
Cancel
Save