dtudcfonted/gpftobdf.c: Coverity CID 175168; NULL deref
authorJon Trulson <jon@radscan.com>
Tue, 3 Apr 2018 00:23:22 +0000 (18:23 -0600)
committerJon Trulson <jon@radscan.com>
Tue, 3 Apr 2018 00:23:22 +0000 (18:23 -0600)
cde/programs/dtudcfonted/dtgpftobdf/gpftobdf.c

index 565f30a61779b10785d9751aff395a3fec52b637..5bea3380e625d8251e89e696f9ce12dab70c11d2 100644 (file)
@@ -1466,9 +1466,19 @@ int      fix ;
 
                bitmap = pcf->bitmaps + getINT32( (unsigned char *)(pcf->offsets + encodingOffset),
                    pcf->bmp_fmt);
-               invertBits( bitmap + bmp_adj, pcf->bmp_fmt, ptn_width, cpy_height, bmp_ptn + ptn_adj);
-               putPtn( (unsigned char *)bmp_ptn, ptn_width, ptn_height );
-               fprintf(stdout,"ENDCHAR\n");
+                /* Only do this if non-NULL... */
+                if (bmp_ptn)
+                {
+                    invertBits( bitmap + bmp_adj, pcf->bmp_fmt,
+                                ptn_width, cpy_height, bmp_ptn + ptn_adj);
+                    putPtn( (unsigned char *)bmp_ptn, ptn_width, ptn_height );
+                }
+                else
+                {
+                    fprintf(stderr, "%s: bmp_ptn is NULL", __FUNCTION__);
+                }
+
+                fprintf(stdout,"ENDCHAR\n");
                if( fix == FALSE )      free(bmp_ptn);
        }
        if( fix == TRUE )       free(bmp_ptn);