)]}'
{
  "commit": "beb0ffd36eedf0542d7f408e87efee4bee3150f8",
  "tree": "228ee5d45bc66f971b603b26d4aaef6af0794912",
  "parents": [
    "53680c1aa92d9f78e8255fbf696c0ed36f160650"
  ],
  "author": {
    "name": "Jonathan Wakely",
    "email": "jwakely@redhat.com",
    "time": "Wed Apr 30 17:31:01 2025 +0100"
  },
  "committer": {
    "name": "Jonathan Wakely",
    "email": "redi@gcc.gnu.org",
    "time": "Mon May 19 10:45:17 2025 +0100"
  },
  "message": "libstdc++: Fix dangling pointer in fs::path::operator+\u003d(*this) [PR120029]\n\nWhen concatenating a path we reallocate the left operand\u0027s storage to\nmake room for the new components being added. When the two operands are\nthe same object, or the right operand is one of the components of the\nleft operand, the reallocation invalidates the pointers that refer\ninto the right operand\u0027s storage.\n\nThe solution in this commit is to detect these aliasing cases and just\ndo the concatenation in terms of the contained string, as that code\nalready handles the case where the string aliases the path. The standard\nspecifies the concatenation in terms of the native() string, so all this\nchange does is disable the optimized implementation of concatenation for\npath objects which attempts to avoid re-parsing the path from the\nconcatenated string.\n\nThe potential loss of performance for this case isn\u0027t likely to be an\nissue, because concatenating a path with itself (or one of its existing\ncomponents) probably isn\u0027t a common use case.\n\nThe Filesystem TS implementation doesn\u0027t have the optimized form of\nconcatenation and always does it in terms of the native string and\nreparsing the whole thing, so doesn\u0027t have this bug. A test is added to\nconfirm that anyway (that test has some slightly different results due\nto different behaviour for trailing slashes and implicit \".\" filenames\nin the TS spec).\n\nlibstdc++-v3/ChangeLog:\n\n\tPR libstdc++/120029\n\t* src/c++17/fs_path.cc (path::operator+\u003d(const path\u0026)): Handle\n\tparameters that alias the path or one of its components.\n\t* testsuite/27_io/filesystem/path/concat/120029.cc: New test.\n\t* testsuite/experimental/filesystem/path/concat/120029.cc: New\n\ttest.\n\n(cherry picked from commit a067cbcdcc5f599a2b7d607e89674533d23c652d)\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "6582f10209a084d394bd159cfb06a080025cb353",
      "old_mode": 33188,
      "old_path": "libstdc++-v3/src/c++17/fs_path.cc",
      "new_id": "215afa08ad25f036e0ea7f778f5e9efb3b7d4763",
      "new_mode": 33188,
      "new_path": "libstdc++-v3/src/c++17/fs_path.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "5153d594b50fd1c0816616ca989b457e0918b223",
      "new_mode": 33188,
      "new_path": "libstdc++-v3/testsuite/27_io/filesystem/path/concat/120029.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "209d96806c6a4d9e20b7c7c761a44a75f672af73",
      "new_mode": 33188,
      "new_path": "libstdc++-v3/testsuite/experimental/filesystem/path/concat/120029.cc"
    }
  ]
}
