Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(remote-desktop): guard missing privacy screen textures
Dash Huang464d6b3554d6
diff --git a/apps/desktop/native/remote-desktop/hyprland-privacy/main.cpp b/apps/desktop/native/remote-desktop/hyprland-privacy/main.cppindex 5d4d3f0d88..26383a24ab 100644--- a/apps/desktop/native/remote-desktop/hyprland-privacy/main.cpp+++ b/apps/desktop/native/remote-desktop/hyprland-privacy/main.cpp@@ -191,7 +191,8 @@ static SP<ITexture> artwork(const unsigned char *bytes, size_t size) {SP<ITexture> texture;if (cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS) {texture = g_pHyprRenderer->createTexture(surface);- texture->m_imageDescription = NColorManagement::DEFAULT_SRGB_IMAGE_DESCRIPTION;+ if (texture)+ texture->m_imageDescription = NColorManagement::DEFAULT_SRGB_IMAGE_DESCRIPTION;}cairo_surface_destroy(surface);return texture;@@ -407,17 +408,20 @@ static bool copy(CHyprOpenGLImpl *self, const CBox &box) {auto texture = g_pHyprRenderer->renderText(label, foreground(), 18, false, "", 510);// Cairo text is sRGB. The final-copy renderer needs an explicit image// description, unlike the ordinary surface pass's implicit fallback.- texture->m_imageDescription = NColorManagement::DEFAULT_SRGB_IMAGE_DESCRIPTION;+ if (texture)+ texture->m_imageDescription = NColorManagement::DEFAULT_SRGB_IMAGE_DESCRIPTION;texts.push_back(texture);}}bool dialog = gate.phase == PrivacyGate::Confirming;const auto scale = dialogScale(monitor);double left = (full.w / scale - 560) / 2, top = (full.h / scale - 220) / 2;- auto text = [&](size_t index, double x, double y) {+ auto text = [&](size_t index, double x, double y, bool centered = false) {if (index >= texts.size() || !texts[index])return;auto size = texts[index]->m_size;+ if (centered)+ x -= size.x / 2;self->renderTexture(texts[index],CBox{x * scale, y * scale, size.x * scale, size.y * scale}, {});@@ -446,8 +450,8 @@ static bool copy(CHyprOpenGLImpl *self, const CBox &box) {self->renderTexture(heroTexture, CBox{heroX * scale, heroY * scale, heroWidth * scale, heroHeight * scale}, {});if (wordmarkTexture)self->renderTexture(wordmarkTexture, CBox{(portrait ? (w - markWidth) / 2 : copyX) * scale, copyY * scale, markWidth * scale, markHeight * scale}, {});- text(0, portrait ? (w - texts[0]->m_size.x) / 2 : copyX, copyY + markHeight + 32);- text(1, portrait ? (w - texts[1]->m_size.x) / 2 : copyX, copyY + markHeight + 100);+ text(0, portrait ? w / 2 : copyX, copyY + markHeight + 32, portrait);+ text(1, portrait ? w / 2 : copyX, copyY + markHeight + 100, portrait);} else {text(2, left + 24, top + 30);text(3, left + 24, top + 78);diff --git a/apps/desktop/native/remote-desktop/hyprland-privacy/test.mjs b/apps/desktop/native/remote-desktop/hyprland-privacy/test.mjsindex 492905b87f..3a211dce8c 100644--- a/apps/desktop/native/remote-desktop/hyprland-privacy/test.mjs+++ b/apps/desktop/native/remote-desktop/hyprland-privacy/test.mjs@@ -6,6 +6,98 @@ import path from 'node:path';import { fileURLToPath } from 'node:url';import test from 'node:test';+test('missing text and artwork textures never dereference null or shift label indices', () => {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'cindy-privacy-textures-'));+ const root = path.dirname(fileURLToPath(import.meta.url));+ try {+ // Compile the actual rendering fragments against failing texture providers.+ // This exercises both the allocation and centered draw paths under UBSan.+ const main = fs.readFileSync(path.join(root, 'main.cpp'), 'utf8');+ const fragment = (start, end) => {+ const from = main.indexOf(start);+ const to = main.indexOf(end, from);+ assert.ok(from >= 0 && to > from, `Missing rendering fragment: ${start}`);+ return main.slice(from, to);+ };+ const artwork = fragment('static SP<ITexture> artwork(', 'static bool active()');+ const labels = fragment(' if (texts.empty()) {', ' bool dialog =');+ const draw = fragment(' auto text =', '\n };') + '\n };';+ assert.ok(artwork && labels && draw.includes('renderTexture'));+ const source = path.join(directory, 'test.cpp');+ fs.writeFileSync(+ source,+ `+#include <algorithm>+#include <cassert>+#include <memory>+#include <string>+#include <vector>+template<class T> using SP = std::shared_ptr<T>;+struct ITexture { struct { double x=100, y=20; } m_size; int m_imageDescription=0; };+struct CBox { double x,y,w,h; };+namespace NColorManagement { constexpr int DEFAULT_SRGB_IMAGE_DESCRIPTION=7; }+constexpr int CAIRO_STATUS_READ_ERROR=1, CAIRO_STATUS_SUCCESS=0;+int destroyed=0;+template<class F> void* cairo_image_surface_create_from_png_stream(F, void*) { return nullptr; }+int cairo_surface_status(void*) { return CAIRO_STATUS_SUCCESS; }+void cairo_surface_destroy(void*) { ++destroyed; }+struct Renderer {+ std::vector<CBox> boxes;+ bool failArtwork=true;+ SP<ITexture> createTexture(void*) { return failArtwork ? nullptr : std::make_shared<ITexture>(); }+ SP<ITexture> renderText(const std::string& label, int, int, bool, const char*, int) {+ return label=="missing" ? nullptr : std::make_shared<ITexture>();+ }+ void renderTexture(SP<ITexture> texture, CBox box, int) { assert(texture); boxes.push_back(box); }+} renderer;+auto* g_pHyprRenderer=&renderer;+int foreground() { return 0; }+${artwork}+void check(std::vector<std::string> labels) {+ std::vector<SP<ITexture>> texts;+ ${labels}+ assert(texts.size()==labels.size());+ double scale=2;+ auto* self=&renderer;+ ${draw}+ renderer.boxes.clear();+ text(99, 200, 30, true);+ assert(renderer.boxes.empty());+ for (size_t i=0;i<labels.size();++i) {+ const auto before=renderer.boxes.size();+ for (bool centered : {false,true}) {+ text(i,200,30,centered);+ if (!texts[i]) { assert(renderer.boxes.size()==before); continue; }+ assert(texts[i]->m_imageDescription==7);+ const auto box=renderer.boxes.back();+ assert(box.x==(centered?300:400) && box.y==60 && box.w==200 && box.h==40);+ }+ }+}+int main() {+ check({"missing","missing","missing","missing","missing","missing"});+ check({"missing","ok","ok","missing","ok","missing"});+ check({"ok","missing","missing","ok","missing","ok"});+ check({});+ assert(!artwork(nullptr,0) && destroyed==1);+ renderer.failArtwork=false;+ assert(artwork(nullptr,0)->m_imageDescription==7 && destroyed==2);+}+`,+ );+ const binary = path.join(directory, 'test');+ for (const [command, args] of [+ ['c++', ['-std=c++20', '-fsanitize=address,undefined', '-g', source, '-o', binary]],+ [binary, []],+ ]) {+ const result = spawnSync(command, args, { encoding: 'utf8', timeout: 60000 });+ assert.equal(result.status, 0, result.stderr || String(result.error));+ }+ } finally {+ fs.rmSync(directory, { recursive: true, force: true });+ }+});+test('physical triggers and held edges never reach the remote application or confirm themselves', () => {const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'cindy-privacy-gate-'));const root = path.dirname(fileURLToPath(import.meta.url));