mib added inline comments.

================
Comment at: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp:320
+
+  std::vector<llvm::StringRef> sorted_keys(keys->GetSize());
+  auto sort_keys = [&sorted_keys](StructuredData::Object *item) -> bool {
----------------
JDevlieghere wrote:
> mib wrote:
> > JDevlieghere wrote:
> > > Won't this overflow when you return the example from the summary?
> > > 
> > > ```
> > > {1: "one", 2: "two", 10: "ten"}
> > > ```
> > > 
> > > Would it be easier to populate our own `map<size_t, ObjectSP>` and 
> > > iterate over that below? 
> > I don't see why it would overflow 🧐
> You create a vector with 3 elements:
> 
> ```
> std::vector<llvm::StringRef> sorted_keys(keys->GetSize());
> ```
> 
> But you use the key from the dictionary to index the vector:
> 
> ```
> sorted_keys[0] = "";
> sorted_keys[1] = "one";
> sorted_keys[2] = "two";
> -- end of vector --
> sorted_keys[10] = "ten"; 
> ```
You're right! I didn't hit this because in the Scripted Process case, indices 
are 0 based, so that works perfectly but I guess I could use a map to prevent a 
potential overflow


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122429/new/

https://reviews.llvm.org/D122429

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to