Skip to content

Commit

Permalink
Merge branch 'master' into 2014_R2
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Cercueil committed May 13, 2015
2 parents c273b2d + 5eca24f commit bd333d7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ struct iio_context * network_create_context(const char *host)
struct addrinfo hints, *res;
struct iio_context *ctx;
struct iio_context_pdata *pdata;
unsigned int i, len;
size_t i, len;
int fd, ret;
char *description;
#ifdef _WIN32
Expand Down Expand Up @@ -1392,15 +1392,16 @@ struct iio_context * network_create_context(const char *host)
#endif

if (ctx->description) {
size_t new_size = len + strlen(ctx->description) + 1;
size_t desc_len = strlen(description);
size_t new_size = desc_len + strlen(ctx->description) + 2;
char *ptr, *new_description = realloc(description, new_size);
if (!new_description) {
ret = -ENOMEM;
goto err_free_description;
}

ptr = strrchr(new_description, '\0');
snprintf(ptr, new_size - len, " %s", ctx->description);
snprintf(ptr, new_size - desc_len, " %s", ctx->description);
free(ctx->description);

ctx->description = new_description;
Expand Down

0 comments on commit bd333d7

Please sign in to comment.