Use the actual string length (without the trailing NUL terminator) for g_strndup(), because it allocates and inserts a trailing NUL byte. --- src/eir.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/src/eir.c b/src/eir.c index ff50cf8..96aa763 100644 --- a/src/eir.c +++ b/src/eir.c @@ -169,8 +169,7 @@ int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len) g_free(eir->name); - eir->name = g_strndup((char *) &eir_data[2], - field_len - 1); + eir->name = g_strndup((char *) &eir_data[2], name_len); eir->name_complete = eir_data[1] == EIR_NAME_COMPLETE; break; } -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html