Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

check strdup #163

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/fetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,15 @@ class Command
static void split(vector<char *> &v, string cmd)
{
istringstream ss{cmd};
for (string arg{}; getline(ss, arg, ' '); )
if (arg != "")
v.push_back(strdup(arg.c_str()));

for (string arg{}; getline(ss, arg, ' '); ) {
if (arg == "")
continue;

auto s = strdup(arg.c_str());
if (s == NULL)
throw runtime_error("strdup failed");
v.push_back(s);
}
v.push_back((char *)0);
}

Expand Down
Loading