What does Windows error code 1462 (ERROR_INCORRECT_SIZE) mean?

 
Previous Next
ERROR_INVALID_MONITOR_HANDLE ERROR_SYMLINK_CLASS_DISABLED

ERROR_INCORRECT_SIZE

A size argument is inconsistent with the requested operation.

ERROR_INCORRECT_SIZE is Win32 error 1462 (0x5B6). It can indicate an invalid buffer length, record size, element count, or cbSize-style structure field. The caller must inspect the exact API contract because the code does not identify which size value was wrong.

Frequent programming causes

  • setting cbSize to the pointer size instead of sizeof(structure)
  • mixing ANSI and Unicode structure or string lengths
  • passing character counts where byte counts are required
  • using a newer or older structure version without the required size
  • integer overflow while calculating header plus payload length

Evidence to preserve

Log every size and count parameter, structure type and version, process architecture, packing assumptions, input buffer length, output capacity, and returned required size if the API provides one. For IPC or driver calls, retain the protocol header and declared payload length after redacting sensitive data.

Diagnostic sequence

Read the documentation for each size field and annotate whether it is measured in bytes, characters, elements, or structure versions. Recalculate in size_t or another wide unsigned type with overflow checks, then validate before narrowing to the API’s parameter type. Confirm structure packing and field offsets at the ABI boundary.

Initialize versioned structures to zero and assign their documented size field explicitly. When calling a query API, distinguish “input size of this structure” from “capacity of the caller’s output buffer.” Do not repeatedly enlarge a buffer when the rejected value is a malformed fixed structure size.

Corrective design

Centralize checked size calculations, use typed span or array abstractions internally, and convert to Win32 units only at the call boundary. Add compile-time assertions for structures shared with drivers or other processes. Treat data from files and networks as untrusted before using embedded lengths.

Difference from buffer-too-small errors

ERROR_INSUFFICIENT_BUFFER usually means the supplied output capacity is valid but too small. Error 1462 more often means the size argument itself is not acceptable for the contract, so retrying with a larger arbitrary value may not help.

Example

A 64-bit binding declares a structure with default language packing instead of the Windows ABI layout. Its cbSize reflects the wrong layout and the API returns 1462. Matching native packing and verifying offsets against the SDK header corrects the call.

References


Looking for a different code? Search another status or error code.