Skip to content

Commit

Permalink
Fix clang static analyzer warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fhanau committed Aug 22, 2022
1 parent 0fdb1c5 commit 1a9414d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/lodepng/lodepng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,9 @@ static void optimize_palette(LodePNGColorMode* mode_out, const uint32_t* image,
const unsigned char* c = (unsigned char*)&image[i];
if (color_tree_inc(&tree, c[0], c[1], c[2], c[3]) == 0) ++count;
}
//Silence clang static analyzer warnings
if (count == 0) {return;}

// sortfield format:
// bit 0-7: original palette index
// bit 8-39: color encoding or popularity index
Expand Down
2 changes: 1 addition & 1 deletion src/zopfli/deflate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ static void DeflateSplittingFirst(const ZopfliOptions* options,
SymbolStats* statsp = 0;
ZopfliBlockSplit(options, in, instart, inend, &splitpoints, &npoints, &statsp, twiceMode, *twiceStore);

ZopfliLZ77Store* stores;
ZopfliLZ77Store* stores = 0;
if (twiceMode & 1){
stores = (ZopfliLZ77Store*)malloc((npoints + 1) * sizeof(ZopfliLZ77Store));
if(!stores){
Expand Down
2 changes: 1 addition & 1 deletion src/zopfli/lz77.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ static int LZ4HC_InsertAndFindBestMatch(LZ4HC_Data_Structure* hc4, /* Index ta
/* HC4 match finder */
LZ4HC_Insert(hc4, ip);
U32 matchIndex = HashTable[LZ4HC_hashPtr(ip)];
if(HashTable[LZ4HC_hashPtr(ip + ml - 3)] < (lowLimit + ml - 3)) {return ml;}
if(HashTable[LZ4HC_hashPtr(ip + ml - 3)] < (lowLimit + ml - 3)) {*matchpos = ip; return ml;}
U32 start = *(unsigned*)ip;
U32 end = *(unsigned*)(ip + ml - 3);

Expand Down

0 comments on commit 1a9414d

Please sign in to comment.