pdmark / openjpeg

Automatically exported from code.google.com/p/openjpeg
Other
0 stars 0 forks source link

a couple of small errors in libopenjpeg detected by coverity #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi all,

I'm a developer for blender(www.blender.org) were using openjpeg and
were also getting scans from coverity.
It detected a mem leak in t2.c

at line 617 it should free pi before returning -999

I can provide the details of the report if needed just let me know.
(They are a bit hard to read
and I figured this one is pretty straight forward)
its:
CID: 570
Checker: RESOURCE_LEAK (help)
File: base/src/extern/libopenjpeg/t2.c
Function: t2_encode_packets
Description: Variable "pi" not freed or pointed-to in function
"pi_create_encode"

There is one other report about some dead code this one I'm providing
the extra details.  I
haven't really looked at this one but figured I'd forward it on.  If
you fix these please note in your svn comments that it was detected by
coverity.  Let me know if this doesn't make sense.

CID: 566
Checker: DEADCODE (help)
File: base/src/extern/libopenjpeg/t1.c
Function: t1_encode_cblk
Description: Assigning "0" to "type"

Event const: After this line, the value of "type" is equal to 0
Event assignment: Assigning "0" to "type"
Also see events: [dead_error_begin][dead_error_condition][assignment]

835                     type = ((bpno < (cblk->numbps - 4)) && (passtype <
2) &&
(cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
836
837                     switch (passtype) {
838                             case 0:
839                                     t1_enc_sigpass(t1, bpno, orient,
&nmsedec, type, cblksty);
840                                     break;
841                             case 1:
842                                     t1_enc_refpass(t1, bpno, &nmsedec,
type, cblksty);
843                                     break;
844                             case 2:
845                                     t1_enc_clnpass(t1, bpno, orient,
&nmsedec, cblksty);
846                                     /* code switch SEGMARK (i.e. SEGSYM) */
847                                     if (cblksty & J2K_CCP_CBLKSTY_SEGSYM)
848                                             mqc_segmark_enc(mqc);
849                                     break;
850                     }
851
852                     /* fixed_quality */
853                     tempwmsedec = t1_getwmsedec(nmsedec, compno, level,
orient,
bpno, qmfbid, stepsize, numcomps);
854                     cumwmsedec += tempwmsedec;
855                     tile->distotile += tempwmsedec;
856
857                     /* Code switch "RESTART" (i.e. TERMALL) */
858                     if ((cblksty & J2K_CCP_CBLKSTY_TERMALL) &&
!((passtype == 2)
&& (bpno - 1 < 0))) {
859                             if (type == T1_TYPE_RAW) {
860                                     mqc_flush(mqc);
861                                     correction = 1;
862                                     /* correction =
mqc_bypass_flush_enc(); */
863                             } else {                        /*
correction = mqc_restart_enc(); */
864                                     mqc_flush(mqc);
865                                     correction = 1;
866                             }
867                             pass->term = 1;
868                     } else {
869                             if (((bpno < (cblk->numbps - 4) &&
(passtype > 0))
870                                     || ((bpno == (cblk->numbps - 4)) &&
(passtype == 2))) &&
(cblksty & J2K_CCP_CBLKSTY_LAZY)) {

Event dead_error_condition: On this path, the condition "type == 1"
could not be true
Also see events: [dead_error_begin][const][assignment]

871                                     if (type == T1_TYPE_RAW) {

Event dead_error_begin: Cannot reach dead code beginning here
Also see events: [dead_error_condition][const][assignment]

872                                             mqc_flush(mqc);

Anyway thanks for the good work and keep it up.

Kent Mein

Original issue reported on code.google.com by mathieu.malaterre on 8 Jun 2009 at 8:18

GoogleCodeExporter commented 9 years ago
Original post:

http://groups.google.com/group/openjpeg/browse_thread/thread/312ef65137c1f9f3

Original comment by mathieu.malaterre on 8 Jun 2009 at 8:19

GoogleCodeExporter commented 9 years ago
This has been fixed in r563. Closing

Original comment by mathieu.malaterre on 11 Jan 2012 at 7:10