diff --git a/mcplayerstat.c b/mcplayerstat.c index 1b41070..2f02ff2 100644 --- a/mcplayerstat.c +++ b/mcplayerstat.c @@ -13,12 +13,14 @@ void printInventory(TagList *inv) { if(!strncmp(attr.name,"Slot",attr.nameLength)) { slot = *((uint8_t*)attr.payload); } else if(!strncmp(attr.name,"id",attr.nameLength)) { - id = (char*)attr.payload; + id = calloc(attr.payloadLength+1,sizeof(char)); + memcpy(id,(char*)attr.payload,attr.payloadLength); } else if(!strncmp(attr.name,"Count",attr.nameLength)) { count = *((uint8_t*)attr.payload); } } printf("\t- [%u] %ux %s\n",slot,count,id); + free(id); } }