GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sqlite: binding a zero-length `Uint8Array` to a parameter can result in `NULL` · Issue #67188 · nodejs/node

sqlite: binding a zero-length Uint8Array to a parameter can result in NULL #67188

New issue
Copy link
New issue
Copy link
Closed
#67657
Closed
sqlite: binding a zero-length Uint8Array to a parameter can result in NULL#67188
#67657
Copy link
Labels
sqliteIssues and PRs related to the SQLite subsystem.v22.xIssues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch.

Description

@duarte-pardal
duarte-pardal
opened on Nov 1, 2026
Issue body actions

Version

v22.23.4

Platform

Linux redacted 7.0.0-38-generic #38~24.04.4-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 14 16:37:11 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

sqlite

What steps will reproduce the bug?

const { DatabaseSync } = require('node:sqlite');
const db = new DatabaseSync(':memory:');

// Expected: prints { type: 'blob' }
console.log(db.prepare('SELECT typeof(?) AS type').get(new Uint8Array()));

// Unexpected: prints { type: 'null' }
console.log(db.prepare('SELECT typeof(?) AS type').get(new Uint8Array(new ArrayBuffer(0))));

How often does it reproduce? Is there a required condition?

The above code seems to reproduce the issue deterministically.

What is the expected behavior? Why is that the expected behavior?

All zero-length Uint8Arrays bound to SQLite parameters should be converted to empty blobs.

What do you see instead?

new Uint8Array(new ArrayBuffer(0)) is converted to NULL.

Additional information

This seems to be fixed in v24 and v26.

My agent (GPT-6.1 Sol on Codex CLI) told me the following:

Reproduced on Node.js v22.23.4. ArrayBufferViewContents returns a non-null stack pointer for new Uint8Array(), but a null backing-store pointer for new Uint8Array(new ArrayBuffer(0)). Node passes that pointer to SQLite, which interprets null pointers as SQL NULL, regardless of length.

v26 includes commit bdf75a6 (PR #62343), which makes the helper fall back to stack storage when the backing-store pointer is null. This fixes the SQLite behavior indirectly; the change originally addressed a crypto bug. Backporting this helper fix would resolve the v22 reproducer.

Activity

  1. Renegade334
    added
    v22.xIssues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch.
    sqliteIssues and PRs related to the SQLite subsystem.
    on Nov 3, 2026
  2. nodejs-github-bot
    closed this as completedin #67657on Nov 22, 2026
  3. dnalborczyk
    added a commit that references this issue on Nov 22, 2026

    sqlite: bind empty ArrayBuffer as empty blob

    ec97d64
  4. aduh95
    added a commit that references this issue on Nov 23, 2026

    sqlite: bind empty ArrayBuffer as empty blob

    cd86a6b
  5. gabylb
    added a commit that references this issue on Nov 27, 2026

    sqlite: bind empty ArrayBuffer as empty blob

    81bcbbc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    sqliteIssues and PRs related to the SQLite subsystem.v22.xIssues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.