discovered the use of strndup()
This commit is contained in:
@@ -169,10 +169,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
|
||||
|
||||
this->directory_flag = (flags & DIRECTORY_CONTENTS_FLAG) !=
|
||||
PTS_REQ_FILE_MEAS_NO_FLAGS;
|
||||
|
||||
this->pathname = malloc(pathname.len + 1);
|
||||
memcpy(this->pathname, pathname.ptr, pathname.len);
|
||||
this->pathname[pathname.len] = '\0';
|
||||
this->pathname = strndup(pathname.ptr, pathname.len);
|
||||
|
||||
reader->destroy(reader);
|
||||
return SUCCESS;
|
||||
|
||||
@@ -162,10 +162,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
|
||||
|
||||
this->directory_flag = (flags & DIRECTORY_CONTENTS_FLAG) !=
|
||||
PTS_REQ_FILE_META_NO_FLAGS;
|
||||
|
||||
this->pathname = malloc(pathname.len + 1);
|
||||
memcpy(this->pathname, pathname.ptr, pathname.len);
|
||||
this->pathname[pathname.len] = '\0';
|
||||
this->pathname = strndup(pathname.ptr, pathname.len);
|
||||
|
||||
reader->destroy(reader);
|
||||
return SUCCESS;
|
||||
|
||||
@@ -252,9 +252,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
|
||||
entry->accessed = accessed;
|
||||
entry->owner = owner;
|
||||
entry->group = group;
|
||||
entry->filename = malloc(filename.len + 1);
|
||||
entry->filename[filename.len] = '\0';
|
||||
memcpy(entry->filename, filename.ptr, filename.len);
|
||||
entry->filename = strndup(filename.ptr, filename.len);
|
||||
|
||||
this->metadata->add(this->metadata, entry);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user