Skip to content

Commit

Permalink
Prevent uninitialized StorePath creation
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Feb 13, 2020
1 parent 94c9343 commit d897231
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/libstore/path.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ extern "C" {

struct StorePath : rust::Value<3 * sizeof(void *) + 24, ffi_StorePath_drop>
{
StorePath() = delete;

static StorePath make(std::string_view path, std::string_view storeDir);

static StorePath make(unsigned char hash[20], std::string_view name);
Expand Down
2 changes: 2 additions & 0 deletions src/libutil/rust-ffi.hh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ extern "C" {

struct String : Vec<char, ffi_String_drop>
{
String() = delete;

String(std::string_view s)
{
ffi_String_new(StringSlice(s), this);
Expand Down
4 changes: 2 additions & 2 deletions src/nix/why-depends.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct CmdWhyDepends : SourceExprCommand
std::map<StorePath, Node> graph;

for (auto & path : closure)
graph.emplace(path.clone(), Node{path.clone(), cloneStorePathSet(store->queryPathInfo(path)->references)});
graph.emplace(path.clone(), Node { .path = path.clone(), .refs = cloneStorePathSet(store->queryPathInfo(path)->references) });

// Transpose the graph.
for (auto & node : graph)
Expand All @@ -112,7 +112,7 @@ struct CmdWhyDepends : SourceExprCommand

/* Run Dijkstra's shortest path algorithm to get the distance
of every path in the closure to 'dependency'. */
graph[dependencyPath.clone()].dist = 0;
graph.emplace(dependencyPath.clone(), Node { .path = dependencyPath.clone(), .dist = 0 });

std::priority_queue<Node *> queue;

Expand Down

0 comments on commit d897231

Please sign in to comment.