Closed algo99 closed 1 year ago
The build fails at link.c on Fedora 37:
link.c
link.o ./link.c: In function ‘ml_getfileannot’: ./link.c:2562:5: error: ‘file_params’ may be used uninitialized [-Werror=maybe-uninitialized] 2562 | pdf_get_embedded_file_params (state.ctx, fs, file_params); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./link.c:2561:31: note: ‘file_params’ was declared here 2561 | pdf_embedded_file_params *file_params; | ^~~~~~~~~~~ cc1: all warnings being treated as errors ocamlc -ccopt "-g -std=c11 -I build/mupdf/include -I build/mupdf/thirdparty/freetype/include -Wall -Werror -Wextra -pedantic -O2 -D_POSIX_C_SOURCE -DGL_H='<GL/gl.h>' -DTEXT_TYPE=GL_TEXTURE_RECTANGLE_ARB -MMD -MF build/link.o.dep -MT_" -o build/link.o -c ./link.c failed build failed
and I think the compiler is right now :) because this code looks suspicious for me
link.c: 2549
ML (getfileannot (value ptr_v, value n_v)) { ... pdf_embedded_file_params *file_params; pdf_get_embedded_file_params (state.ctx, fs, file_params); ret_v = caml_copy_string (file_params->filename); ... }
because function pdf_get_embedded_file_params does not allocate memory for file_params structure.
pdf_get_embedded_file_params
file_params
Not sure though why you don't see this error. I used system ocaml-14.4.0 and Fedora-37 has gcc-12.2.1
extremely confusing why i dont get any of the errors others get. i have implemented your patch though
The build fails at
link.c
on Fedora 37:and I think the compiler is right now :) because this code looks suspicious for me
link.c: 2549
because function
pdf_get_embedded_file_params
does not allocate memory forfile_params
structure.This patch solves the problem:
```diff diff --git a/link.c b/link.c index 7bbf73a..ecf6189 100644 --- a/link.c +++ b/link.c @@ -2558,9 +2558,9 @@ ML (getfileannot (value ptr_v, value n_v)) pdf_obj *fs = pdf_dict_get (state.ctx, pdf_annot_obj (state.ctx, slink->u.annot), PDF_NAME (FS)); - pdf_embedded_file_params *file_params; - pdf_get_embedded_file_params (state.ctx, fs, file_params); - ret_v = caml_copy_string (file_params->filename); + pdf_embedded_file_params file_params; + pdf_get_embedded_file_params (state.ctx, fs, &file_params); + ret_v = caml_copy_string (file_params.filename); unlock (__func__); CAMLreturn (ret_v); ```Not sure though why you don't see this error. I used system ocaml-14.4.0 and Fedora-37 has gcc-12.2.1