Skip to content

Commit e77521a

Browse files
committed
Fix memcpy to nullptr (commit 7e43168)
1 parent b993543 commit e77521a

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

libhdt/src/libdcs/CSD_HTFC.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* Miguel A. Martinez-Prieto: migumar2@infor.uva.es
2626
*/
2727

28+
#include <string>
2829
#include "CSD_HTFC.h"
2930

3031
#if HAVE_CDS
@@ -57,8 +58,9 @@ CSD_HTFC::CSD_HTFC(hdt::IteratorUCharString *it, uint32_t blocksize,
5758

5859
vector<uint> xblocks; // Temporal storage for start positions
5960

60-
unsigned char *previousStr = NULL, *currentStr = NULL;
61-
uint previousLength = 0, currentLength = 0;
61+
std::basic_string<unsigned char> previousStr((const unsigned char*)"");
62+
unsigned char *currentStr = NULL;
63+
uint currentLength = 0;
6264

6365
while (it->hasNext()) {
6466
currentStr = it->next();
@@ -99,8 +101,8 @@ CSD_HTFC::CSD_HTFC(hdt::IteratorUCharString *it, uint32_t blocksize,
99101
// Regular string
100102

101103
// Calculating the length of the long common prefix
102-
uint delta = longest_common_prefix(previousStr, currentStr,
103-
previousLength, currentLength);
104+
uint delta = longest_common_prefix(previousStr.data(), currentStr,
105+
previousStr.length(), currentLength);
104106

105107
// cout << "Block: " << nblocks << " Pos: "<< length << endl;
106108
// cout << previousStr << endl << currentStr << endl << " Delta: " <<
@@ -121,8 +123,7 @@ CSD_HTFC::CSD_HTFC(hdt::IteratorUCharString *it, uint32_t blocksize,
121123

122124
// New string processed
123125
numstrings++;
124-
memcpy(previousStr, currentStr, currentLength);
125-
previousLength = currentLength;
126+
previousStr.assign(currentStr, currentLength);
126127

127128
it->freeStr(currentStr);
128129
// NOTIFYCOND(listener, "Converting dictionary to HTFC", length,

0 commit comments

Comments
 (0)