Skip to content

Conversation

@mir-huzaif
Copy link
Contributor

No description provided.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
55.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes buffer size handling for wide characters (wchar_t) on Windows. The underlying licensing API expects character counts rather than byte counts, and on Windows, each wide character is 2 bytes, requiring proper conversion.

Key Changes:

  • Added getCharCount() helper function in C++ to convert byte lengths to character counts, with validation for UTF-16 alignment on Windows
  • Added getCArray() helper function in TypeScript to create appropriately-sized buffers (2x size on Windows for wchar_t)
  • Updated all 13 affected native function bindings to use the new conversion logic

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 13 comments.

File Description
src/native/main.cpp Added getCharCount() function and updated 13 functions to properly convert byte lengths to character counts for buffer operations
src/lexfloatclient.ts Updated all buffer allocations to use getCArray() helper instead of direct Uint8Array construction
src/lexfloatclient-native.ts Added getCArray() helper function to allocate platform-appropriate buffer sizes (2x on Windows)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Napi::Uint8Array array = info[0].As<Napi::Uint8Array>();
size_t length = array.ElementLength();
size_t length = getCharCount(env, array.ByteLength());
if(env.IsExceptionPending()) {
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

The opening brace style is inconsistent with the rest of the codebase. The established convention in this file is to place opening braces on a new line for if statements. Consider changing to match the existing style for consistency.

Copilot uses AI. Check for mistakes.
Napi::Uint8Array array = info[0].As<Napi::Uint8Array>();
size_t length = array.ElementLength();
size_t length = getCharCount(env, array.ByteLength());
if(env.IsExceptionPending()) {
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

The opening brace style is inconsistent with the rest of the codebase. The established convention in this file is to place opening braces on a new line for if statements. Consider changing to match the existing style for consistency.

Copilot uses AI. Check for mistakes.
Napi::Uint8Array array = info[1].As<Napi::Uint8Array>();
size_t length = array.ElementLength();
size_t length = getCharCount(env, array.ByteLength());
if(env.IsExceptionPending()) {
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

The opening brace style is inconsistent with the rest of the codebase. The established convention in this file is to place opening braces on a new line for if statements. Consider changing to match the existing style for consistency.

Copilot uses AI. Check for mistakes.
Napi::Uint8Array array = info[0].As<Napi::Uint8Array>();
size_t length = array.ElementLength();
size_t length = getCharCount(env, array.ByteLength());
if(env.IsExceptionPending()) {
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

The opening brace style is inconsistent with the rest of the codebase. The established convention in this file is to place opening braces on a new line for if statements. Consider changing to match the existing style for consistency.

Copilot uses AI. Check for mistakes.
CHARTYPE *arg2 = reinterpret_cast<CHARTYPE *>(array2.ArrayBuffer().Data());
size_t length = array2.ElementLength();
size_t length = getCharCount(env, array2.ByteLength());
if(env.IsExceptionPending()) {
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

The opening brace style is inconsistent with the rest of the codebase. The established convention in this file is to place opening braces on a new line for if statements. Consider changing to match the existing style for consistency.

Copilot uses AI. Check for mistakes.
Napi::Uint8Array array = info[1].As<Napi::Uint8Array>();
size_t length = array.ElementLength();
size_t length = getCharCount(env, array.ByteLength());
if(env.IsExceptionPending()) {
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

The opening brace style is inconsistent with the rest of the codebase. The established convention in this file is to place opening braces on a new line for if statements. Consider changing to match the existing style for consistency.

Copilot uses AI. Check for mistakes.
Napi::Uint8Array array = info[0].As<Napi::Uint8Array>();
size_t length = array.ElementLength();
size_t length = getCharCount(env, array.ByteLength());
if(env.IsExceptionPending()) {
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

The opening brace style is inconsistent with the rest of the codebase. The established convention in this file is to place opening braces on a new line for if statements. Consider changing to match the existing style for consistency.

Copilot uses AI. Check for mistakes.
Napi::Uint8Array array = info[0].As<Napi::Uint8Array>();
size_t length = array.ElementLength();
size_t length = getCharCount(env, array.ByteLength());
if(env.IsExceptionPending()) {
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

The opening brace style is inconsistent with the rest of the codebase. The established convention in this file is to place opening braces on a new line for if statements. Consider changing to match the existing style for consistency.

Copilot uses AI. Check for mistakes.
Napi::Uint8Array array = info[0].As<Napi::Uint8Array>();
size_t length = array.ElementLength();
size_t length = getCharCount(env, array.ByteLength());
if(env.IsExceptionPending()) {
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

The opening brace style is inconsistent with the rest of the codebase. The established convention in this file is to place opening braces on a new line for if statements, as seen in other functions (e.g., lines 72-75, 77-80, 112-115). Consider changing to match the existing style for consistency.

Copilot uses AI. Check for mistakes.
Napi::Uint8Array array = info[0].As<Napi::Uint8Array>();
size_t length = array.ElementLength();
size_t length = getCharCount(env, array.ByteLength());
if(env.IsExceptionPending()) {
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

The opening brace style is inconsistent with the rest of the codebase. The established convention in this file is to place opening braces on a new line for if statements. Consider changing to match the existing style for consistency.

Copilot uses AI. Check for mistakes.
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.

2 participants