Skip to content

Commit 8666582

Browse files
authored
Merge pull request #122 from yossigo/fix/memory-glitches
Fix some memory issues.
2 parents e51c335 + 928aa14 commit 8666582

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cluster_client.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ bool cluster_client::connect_shard_connection(shard_connection* sc, char* addres
209209
memcpy(ci.addr_buf, addr_info->ai_addr, addr_info->ai_addrlen);
210210
ci.ci_addr = (struct sockaddr *) ci.addr_buf;
211211
ci.ci_addrlen = addr_info->ai_addrlen;
212+
freeaddrinfo(addr_info);
212213

213214
// call connect
214215
res = sc->connect(&ci);
@@ -240,7 +241,7 @@ void cluster_client::handle_cluster_slots(protocol_response *r) {
240241

241242
// port
242243
bulk_el* mbulk_port_el = shard->mbulks_elements[2]->as_mbulk_size()->mbulks_elements[1]->as_bulk();
243-
char* port = (char*) malloc(mbulk_port_el->value_len);
244+
char* port = (char*) malloc(mbulk_port_el->value_len + 1);
244245
memcpy(port, mbulk_port_el->value + 1, mbulk_port_el->value_len);
245246
port[mbulk_port_el->value_len] = '\0';
246247

protocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class redis_protocol : public abstract_protocol {
165165
mbulk_size_el* m_current_mbulk;
166166

167167
public:
168-
redis_protocol() : m_response_state(rs_initial), m_bulk_len(0), m_response_len(0) { }
168+
redis_protocol() : m_response_state(rs_initial), m_bulk_len(0), m_response_len(0), m_total_bulks_count(0), m_current_mbulk(NULL) { }
169169
virtual redis_protocol* clone(void) { return new redis_protocol(); }
170170
virtual int select_db(int db);
171171
virtual int authenticate(const char *credentials);

0 commit comments

Comments
 (0)