What does Windows error code 122 (ERROR_INSUFFICIENT_BUFFER) mean?

 
Could be also:
ConstantTypeOS
EOPNOTSUPPerrnoSolaris
ENOMSGerrnoWindows
KERNEL_DATA_INPAGE_ERRORBugCheck CodeWindows
Previous Next
ERROR_SEM_TIMEOUT ERROR_INVALID_NAME

ERROR_INSUFFICIENT_BUFFER

The API requires a larger data area

ERROR_INSUFFICIENT_BUFFER commonly appears in two-call Windows API patterns: the caller first asks for the required size, allocates storage, and then repeats the call. The size may be expressed in bytes or characters, so the individual function contract is essential.

Correct handling

  • Read the returned required length before reallocating.
  • Check whether the count includes the terminating null character.
  • Use overflow-safe arithmetic when converting elements to bytes.
  • Allow for the result to grow between the sizing and retrieval calls.

Common mistakes

Frequent causes include passing sizeof(pointer) instead of the buffer capacity, mixing ANSI and Unicode element sizes, forgetting structure version fields, and treating the reported requirement as a byte count when it is a character count. Retry with a suitably larger buffer and a bounded growth policy; an unchanged tiny size after several attempts may indicate an incorrect prototype or corrupted output parameter.

References


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