2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-05 16:12:13 +00:00

Pl_QPDFTokenizer: Use unsigned_char_pointer instead of copy

This commit is contained in:
Jay Berkenbilt 2018-01-22 19:23:42 -05:00
parent 13d9756a45
commit 633fb414af

View File

@ -2,6 +2,7 @@
#include <qpdf/QPDF_String.hh> #include <qpdf/QPDF_String.hh>
#include <qpdf/QPDF_Name.hh> #include <qpdf/QPDF_Name.hh>
#include <qpdf/QTC.hh> #include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
#include <stdexcept> #include <stdexcept>
#include <string.h> #include <string.h>
@ -26,10 +27,7 @@ Pl_QPDFTokenizer::writeNext(char const* buf, size_t len)
{ {
if (len) if (len)
{ {
unsigned char* t = new unsigned char[len]; getNext()->write(QUtil::unsigned_char_pointer(buf), len);
memcpy(t, buf, len);
getNext()->write(t, len);
delete [] t;
this->just_wrote_nl = (buf[len-1] == '\n'); this->just_wrote_nl = (buf[len-1] == '\n');
} }
} }