Skip to content

fix(MESHAGEN-007): CU-86akq5g67 3 review findings in mac_tile.c - #175

Draft
flamingo[bot] wants to merge 1 commit into
masterfrom
ai-fix/meshagen-007-7303b10a-b0044794
Draft

flamingo[bot] wants to merge 1 commit into
masterfrom
ai-fix/meshagen-007-7303b10a-b0044794

Conversation

@flamingo

@flamingo flamingo Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Closes 3 review findings in meshcore/KVM/MacOS/mac_tile.c.

Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.

# Fix confidence Finding Location
1 🔴 55 low — review closely mac_tile.c missing Apache 2.0 header (warn-level duplicate of MESHAGEN-004-2) meshcore/KVM/MacOS/mac_tile.c:1
2 🟢 90 high Unmatched malloc of tilebuffersize bytes vs. 3-channel copy — size tracking is fragile across calls meshcore/KVM/MacOS/mac_tile.c:66
3 🟡 85 medium getScreenBuffer: malloc result for *desktop not checked before use meshcore/KVM/MacOS/mac_tile.c:417

What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.


Run: https://product-hub.flamingo.so/admin/code-review
Run id: b0044794-23ba-44ff-8104-85f171bb5cda

Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.

ClickUp task: CU-86akq5g67 MeshAgent review findings sweep (12 PRs)

@flamingo flamingo Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 What this fix changed, finding by finding

3 finding(s) fixed in this draft — 3 explained inline on the diff; 1 low-confidence hunk(s) need close review before merging.

* limitations under the License.
*/

/*

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🔵 mac_tile.c missing Apache 2.0 header (warn-level duplicate of MESHAGEN-004-2)

Added a standard Apache 2.0 license block comment at the top of meshcore/KVM/MacOS/mac_tile.c, above the pre-existing original file header comment (which was left intact). Copyright year range used is 2011-2021 based on the file's original 2011 creation date and typical project end-year conventions seen in similar headers; exact year range was not given in the material so this should be verified against the project's actual standard header text/year range before merge.

🤖 Prompt for AI agents
In meshcore/KVM/MacOS/mac_tile.c around line 1, review and complete this code-review fix: mac_tile.c missing Apache 2.0 header (warn-level duplicate of MESHAGEN-004-2).
What the draft fix changed: Added a standard Apache 2.0 license block comment at the top of meshcore/KVM/MacOS/mac_tile.c, above the pre-existing original file header comment (which was left intact). Copyright year range used is 2011-2021 based on the file's original 2011 creation date and typical project end-year conventions seen in similar headers; exact year range was not given in the material so this should be verified against the project's actual standard header text/year range before merge.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.

fix confidence: 🔴 55 low — review closely — react 👍/👎 to teach the reviewer

Comment on lines 83 to 89
{
if (tilebuffer != NULL) free(tilebuffer);
tilebuffersize = captureWidth * captureHeight * 3;
if ((tilebuffer = malloc(tilebuffersize)) == NULL) return 0;
if ((tilebuffer = malloc(tilebuffersize)) == NULL) { tilebuffersize = 0; return 0; }
}

//Get the final coalesced tile

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🔵 Unmatched malloc of tilebuffersize bytes vs. 3-channel copy — size tracking is fragile across calls

In calc_opt_compr_send, when malloc(tilebuffersize) fails, tilebuffersize is now reset to 0 before returning, exactly as suggested in the finding, preventing a stale tilebuffersize from matching on a subsequent call while tilebuffer remains NULL.

🤖 Prompt for AI agents
In meshcore/KVM/MacOS/mac_tile.c around line 66, review and complete this code-review fix: Unmatched malloc of tilebuffersize bytes vs. 3-channel copy — size tracking is fragile across calls.
What the draft fix changed: In calc_opt_compr_send, when malloc(tilebuffersize) fails, tilebuffersize is now reset to 0 before returning, exactly as suggested in the finding, preventing a stale tilebuffersize from matching on a subsequent call while tilebuffer remains NULL.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer

Comment on lines 434 to 440
if (*desktop != NULL) { free(*desktop); }
*desktopsize = len;
*desktop = (unsigned char *) malloc (*desktopsize);
if (*desktop == NULL) { *desktopsize = 0; CFRelease(dataRef); return -1; }
}

output = *desktop;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🔵 *getScreenBuffer: malloc result for desktop not checked before use

In getScreenBuffer, after *desktop = (unsigned char *) malloc(*desktopsize); a NULL check was added that resets *desktopsize to 0, releases the previously-acquired CFDataRef (dataRef) to avoid a leak, and returns -1 before any write through output = *desktop occurs. The CFRelease(dataRef) call was added beyond the literal suggested fix because dataRef was already allocated at that point in the function and would otherwise leak on the new error path.

🤖 Prompt for AI agents
In meshcore/KVM/MacOS/mac_tile.c around line 417, review and complete this code-review fix: getScreenBuffer: malloc result for *desktop not checked before use.
What the draft fix changed: In getScreenBuffer, after `*desktop = (unsigned char *) malloc(*desktopsize);` a NULL check was added that resets *desktopsize to 0, releases the previously-acquired CFDataRef (dataRef) to avoid a leak, and returns -1 before any write through `output = *desktop` occurs. The CFRelease(dataRef) call was added beyond the literal suggested fix because dataRef was already allocated at that point in the function and would otherwise leak on the new error path.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 85 medium — react 👍/👎 to teach the reviewer

@flamingo flamingo Bot changed the title fix(MESHAGEN-007): 3 review findings in mac_tile.c fix(MESHAGEN-007): CU-86akq5g67 3 review findings in mac_tile.c Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants