Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c101a963 authored by Suyog Pawar's avatar Suyog Pawar
Browse files

CCodec: Replace strtok with thread safe strtok_r method

Bug: 325549730
Bug: 299191092
Test: ./ccodec_unit_test \
  --gtest_filter=CCodecConfigTest.SetRegionOfInterestParams

Change-Id: I9c76dc8553f116654db889d8b50cdf392983cbe4
parent cf076344
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1896,7 +1896,8 @@ ReflectedParamUpdater::Dict CCodecConfig::getReflectedFormat(
                std::vector<C2QpOffsetRectStruct> c2QpOffsetRects;
                char mutableStrQpOffsetRects[strlen(qpOffsetRects.c_str()) + 1];
                strcpy(mutableStrQpOffsetRects, qpOffsetRects.c_str());
                char* box = strtok(mutableStrQpOffsetRects, ";");
                char* savePtr;
                char* box = strtok_r(mutableStrQpOffsetRects, ";", &savePtr);
                while (box != nullptr) {
                    int top, left, bottom, right, offset;
                    if (sscanf(box, "%d,%d-%d,%d=%d", &top, &left, &bottom, &right, &offset) == 5) {
@@ -1914,7 +1915,7 @@ ReflectedParamUpdater::Dict CCodecConfig::getReflectedFormat(
                    } else {
                        ALOGE("Rects configuration %s doesn't follow the string pattern.", box);
                    }
                    box = strtok(nullptr, ";");
                    box = strtok_r(nullptr, ";", &savePtr);
                }
                if (c2QpOffsetRects.size() != 0) {
                    const std::unique_ptr<C2StreamQpOffsetRects::output> regions =