X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=ED2KLink.cpp;h=7f1ec664b14dff9996de44a7644efaa9b9d9ac3b;hb=80ddd7c4c2b1e9965df13b552538415d3caf8a83;hp=5f33ce872b97c714975bb23ffccfa84b9a96096e;hpb=123951f2009e356a8c4a2f834252c5d974c36558;p=ecparse.git diff --git a/ED2KLink.cpp b/ED2KLink.cpp index 5f33ce8..7f1ec66 100644 --- a/ED2KLink.cpp +++ b/ED2KLink.cpp @@ -18,14 +18,14 @@ static int getDigits(size_t number) { } ED2KLink::ED2KLink(const char* filename, const size_t size, const void* hash) { - this->filename = (char*) malloc(strlen(filename)); + this->filename = (char*) malloc(strlen(filename) + 1); this->hash = malloc(16); strcpy(this->filename, filename); memcpy(this->hash, hash, 16); this->size = size; - link = (char*) calloc(13 + (strlen(filename) + 1) + 1 + getDigits(size) + 1 + 32 + 2, 1); + link = (char*) calloc(13 + strlen(filename) + 1 + getDigits(size) + 1 + 32 + 2 + 1, 1); sprintf(link, "ed2k://|file|%s|%u|", filename, size); for (int i = 0; i < 16; i++) { sprintf(link + strlen(link), "%02X", ((unsigned char*) hash)[i] & 0xff); @@ -71,7 +71,7 @@ ED2KLink* ED2KLink::parseED2KLink(const char* buffer) { stringLength = (char*) pipeIndex - tempBuffer; filename = (char*) malloc(stringLength + 1); memcpy(filename, tempBuffer, stringLength); - sizeString[stringLength] = '\0'; + filename[stringLength] = '\0'; tempBuffer = pipeIndex + 1; GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] parsed filename: “%s”.\n", __FILE__, __LINE__, filename);