Skip to content

Commit

Permalink
PVS-Studio fixes. closes gh-50
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbes committed Feb 16, 2017
1 parent 764adca commit 213ed9f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tnt/tnt_auth.c
Expand Up @@ -76,11 +76,11 @@ tnt_auth_raw(struct tnt_stream *s, const char *user, int ulen,
v[3].iov_len = ulen;
body_start = data;
data = mp_encode_uint(data, TNT_TUPLE);
char salt[64], scramble[TNT_SCRAMBLE_SIZE];
if (!guest) {
data = mp_encode_array(data, 2);
data = mp_encode_str(data, "chap-sha1", strlen("chap-sha1"));
data = mp_encode_strl(data, TNT_SCRAMBLE_SIZE);
char salt[64], scramble[TNT_SCRAMBLE_SIZE];
base64_decode(base64_salt, TNT_SALT_SIZE, salt, 64);
tnt_scramble_prepare(scramble, salt, pass, plen);
v[5].iov_base = scramble;
Expand Down
3 changes: 2 additions & 1 deletion tnt/tnt_io.c
Expand Up @@ -68,7 +68,8 @@ tnt_io_resolve(struct sockaddr_in *addr,
addr->sin_family = AF_INET;
addr->sin_port = htons(port);
struct addrinfo *addr_info = NULL;
if (getaddrinfo(hostname, NULL, NULL, &addr_info) == 0) {
if (getaddrinfo(hostname, NULL, NULL, &addr_info) == 0 &&
addr_info != NULL) {
memcpy(&addr->sin_addr,
(void*)&((struct sockaddr_in *)addr_info->ai_addr)->sin_addr,
sizeof(addr->sin_addr));
Expand Down
2 changes: 1 addition & 1 deletion tnt/tnt_object.c
Expand Up @@ -332,7 +332,7 @@ ssize_t tnt_object_vformat(struct tnt_stream *s, const char *fmt, va_list vl)
if ((rv = tnt_object_add_map(s, 0)) == -1)
return -1;
result += rv;
} if (f[0] == ']' || f[0] == '}') {
} else if (f[0] == ']' || f[0] == '}') {
if ((rv = tnt_object_container_close(s)) == -1)
return -1;
result += rv;
Expand Down
9 changes: 5 additions & 4 deletions tnt/tnt_request.c
Expand Up @@ -312,11 +312,12 @@ tnt_request_writeout(struct tnt_stream *s, struct tnt_request *req,
v[v_sz++].iov_len = pos - begin;
}
mp_encode_map(map, nd);
size_t plen = 0; nd = 0;

size_t plen = 0;
for (int i = 1; i < v_sz; ++i) plen += v[i].iov_len;
nd = mp_sizeof_luint32(plen);
v[0].iov_base -= nd;
v[0].iov_len += nd;
size_t hlen = mp_sizeof_luint32(plen);
v[0].iov_base -= hlen;
v[0].iov_len += hlen;
mp_encode_luint32(v[0].iov_base, plen);
ssize_t rv = s->writev(s, v, v_sz);
if (rv == -1)
Expand Down
2 changes: 1 addition & 1 deletion tnt/tnt_schema.c
Expand Up @@ -300,7 +300,7 @@ void tnt_schema_flush(struct tnt_schema *obj) {

void tnt_schema_free(struct tnt_schema *obj) {
if (obj == NULL)
return NULL;
return;
tnt_schema_space_free(obj->space_hash);
mh_assoc_delete(obj->space_hash);
}
Expand Down

0 comments on commit 213ed9f

Please sign in to comment.