Skip to content

Commit 3e7465c

Browse files
committed
session BUGFIX memory leak
1 parent c998190 commit 3e7465c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/session.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ _nc_server_get_cpblts_version(const struct ly_ctx *ctx, LYS_VERSION version, int
11411141
int features_count = 0, dev_count = 0, str_len, len;
11421142
uint32_t i, count;
11431143
LY_ARRAY_COUNT_TYPE v;
1144-
char *yl_content_id;
1144+
char *yl_content_id = NULL;
11451145
uint32_t wd_also_supported, wd_basic_mode;
11461146

11471147
#define NC_CPBLT_BUF_LEN 4096
@@ -1266,7 +1266,7 @@ _nc_server_get_cpblts_version(const struct ly_ctx *ctx, LYS_VERSION version, int
12661266
} else {
12671267
yl_content_id = malloc(11);
12681268
NC_CHECK_ERRMEM_GOTO(!yl_content_id, , unlock_error);
1269-
sprintf(yl_content_id, "%u", ly_ctx_get_change_count(ctx));
1269+
sprintf(yl_content_id, "%" PRIu32, ly_ctx_get_change_count(ctx));
12701270
}
12711271

12721272
if (!strcmp(mod->revision, "2019-01-04")) {
@@ -1281,6 +1281,7 @@ _nc_server_get_cpblts_version(const struct ly_ctx *ctx, LYS_VERSION version, int
12811281
NC_CHECK_GOTO(nc_add_cpblt(str, &cpblts, &count), error);
12821282
}
12831283
free(yl_content_id);
1284+
yl_content_id = NULL;
12841285
continue;
12851286
} else if (mod->version != version) {
12861287
/* skip YANG 1.0 or 1.1 modules */
@@ -1352,6 +1353,7 @@ _nc_server_get_cpblts_version(const struct ly_ctx *ctx, LYS_VERSION version, int
13521353
}
13531354
free(cpblts);
13541355
}
1356+
free(yl_content_id);
13551357
return NULL;
13561358
}
13571359

0 commit comments

Comments
 (0)