Commit e0c75da2 authored by Max Kellermann's avatar Max Kellermann

playlist/cue/parser: pass StringView to Feed()

parent 34bb53a2
......@@ -21,6 +21,7 @@
#include "tag/ParseName.hxx"
#include "util/Alloc.hxx"
#include "util/StringStrip.hxx"
#include "util/StringView.hxx"
#include "util/CharUtil.hxx"
#include <cassert>
......@@ -271,12 +272,11 @@ CueParser::Feed2(char *p) noexcept
}
void
CueParser::Feed(const char *line) noexcept
CueParser::Feed(StringView line) noexcept
{
assert(!end);
assert(line != nullptr);
char *allocated = xstrdup(line);
char *allocated = xstrndup(line.data, line.size);
Feed2(allocated);
free(allocated);
}
......
......@@ -27,6 +27,8 @@
#include <string>
#include <memory>
struct StringView;
class CueParser {
enum {
/**
......@@ -104,7 +106,7 @@ public:
* Feed a text line from the CUE file into the parser. Call
* Get() after this to see if a song has been finished.
*/
void Feed(const char *line) noexcept;
void Feed(StringView line) noexcept;
/**
* Tell the parser that the end of the file has been reached. Call
......
......@@ -22,6 +22,7 @@
#include "../SongEnumerator.hxx"
#include "../cue/CueParser.hxx"
#include "input/TextInputStream.hxx"
#include "util/StringView.hxx"
class CuePlaylist final : public SongEnumerator {
TextInputStream tis;
......
#include "playlist/cue/CueParser.hxx"
#include "util/IterableSplitString.hxx"
#include <string>
#include <string_view>
#include "util/StringView.hxx"
extern "C" {
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
......@@ -15,7 +13,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
const std::string_view src{(const char *)data, size};
for (const auto line : IterableSplitString(src, '\n')) {
parser.Feed(std::string(line).c_str());
parser.Feed(line);
parser.Get();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment