DrKLO/Telegram · error
%s\n
Error message
%s\n
What it means
This is the libjpeg/mozjpeg default error_exit handler: it formats the active JPEG error message via format_message into a buffer and prints it to stderr with a newline. It is the catch-all emitter for every JPEG library error that routes through the error manager; the '%s' is the formatted message text, not a specific error.
Source
Thrown at TMessagesProj/jni/mozjpeg/jerror.c:110
* C stdio library, you may have to delete the call to fprintf() entirely,
* not just not use this routine.
*/
METHODDEF(void)
output_message(j_common_ptr cinfo)
{
char buffer[JMSG_LENGTH_MAX];
/* Create the message */
(*cinfo->err->format_message) (cinfo, buffer);
#ifdef USE_WINDOWS_MESSAGEBOX
/* Display it in a message dialog box */
MessageBox(GetActiveWindow(), buffer, "JPEG Library Error",
MB_OK | MB_ICONERROR);
#else
/* Send it to stderr, adding a newline */
fprintf(stderr, "%s\n", buffer);
#endif
}
/*
* Decide whether to emit a trace or warning message.
* msg_level is one of:
* -1: recoverable corrupt-data warning, may want to abort.
* 0: important advisory messages (always display to user).
* 1: first level of tracing detail.
* 2,3,...: successively more detailed tracing messages.
* An application might override this method if it wanted to abort on warnings
* or change the policy about which messages to display.
*/
METHODDEF(void)
emit_message(j_common_ptr cinfo, int msg_level)
{View on GitHub (pinned to 45ab8f4308)
Solutions
- Read the formatted message text (the %s) to identify the specific JERR_* code and address that root cause.
- Install a custom error_exit to capture cinfo->err->msg_code for programmatic handling instead of relying on text.
- Validate input is a well-formed JPEG (SOI/EOI markers, correct segment lengths) before decoding.
- On Windows the same path can raise a MessageBox via USE_WINDOWS_MESSAGEBOX; disable that define for headless builds.
Example fix
// before: default handler prints + aborts
// after: custom error_exit captures the code
struct my_err { struct jpeg_error_mgr pub; j_msg_code_t code; };
static void my_exit(j_common_ptr cinfo) {
((struct my_err*)cinfo->err)->code = cinfo->err->msg_code;
longjmp(((struct my_err*)cinfo->err)->setjmp_buf, 1);
} Defensive patterns
Strategy: try-catch
Try / catch
#include <jpeglib.h>
#include <setjmp.h>
struct err_jmp { struct jpeg_error_mgr pub; jmp_buf jb; };
static void my_err_exit(j_common_ptr c) {
longjmp(((struct err_jmp*)c->err)->jb, 1);
}
/* setup */
struct err_jmp e;
cinfo.err = jpeg_std_error(&e.pub);
e.pub.error_exit = my_err_exit;
if (setjmp(e.jb)) {
char buf[JMSG_LENGTH_MAX];
cinfo.err->format_message((j_common_ptr)&cinfo, buf);
/* handle buf / msg_code here instead of aborting */
jpeg_destroy_decompress(&cinfo);
return -1;
} Prevention
- Always install a custom error_exit with setjmp/longjmp to avoid process abort.
- Validate input JPEG markers (SOI at 0xFFD8) before decoding.
- Log cinfo->err->msg_code for programmatic handling, not message text.
When it happens
Trigger: Any internal libjpeg error (e.g. corrupt JPEG data, unsupported marker, bad Huffman table, wrong number of components) that calls ERREXIT/ERREXIT2 and uses the default error_exit. The buffer content is determined by cinfo->err->msg_code and format_message.
Common situations: Feeding truncated or non-JPEG data to the decoder, mismatched colorspace parameters, corrupt quantization/Huffman tables, or an API misuse the library detects internally. This line is where ALL such errors become visible text.
Related errors
- %s: sorry, arithmetic coding not supported
- %s: missing argument for dct
- %s: invalid argument for dct
- %s: missing argument for dc-scan-opt
- %s: sorry, entropy optimization was not compiled in
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/55d1518357505b2d.
Report an issue: GitHub.