Source code is GuestBytes* gb = malloc(sizeof(GuestBytes)); assert(gb); if (feof(f)) return NULL; Maybe better code if (feof(f)) return NULL; GuestBytes* gb = malloc(sizeof(GuestBytes)); assert(gb);
Did you come across this just by looking at the code? Or using a static analysis tool? Or a runtime error? The change looks safe to make.
(In reply to Paul Floyd from comment #1) > Did you come across this just by looking at the code? Or using a static > analysis tool? Option 2. Static analyser cppcheck.
Created attachment 133113 [details] Patch as suggested
(In reply to Paul Floyd from comment #3) > Created attachment 133113 [details] > Patch as suggested Although technically correct I am not sure how useful this file is. I don't know how to build it.
It's simple to build: gcc -g -o smchash smchash.c Running it is a bit more complicated. You need to generate in input file to test first, say something like this ../../vg-in-place --trace-notabove=10000 --trace-flags=10000000 --vex-guest-chase=no pwd 2>&1 | grep Guest > hash.in Then the test tool can be run ./smchash < hash.in I don't really understand the stats generated. Finally, cppcheck is probably being a bit pessimistic. 'read_one' is called from a while loop from apply_to_all that already checks !feof.
I don't think this is worth bothering with. It's not part of the build. It's just a program I hacked up to collect stats used to develop the hash functions that you see at the bottom of VEX/priv/guest_generic_bb_to_IR.c.
Oh well. It's already gone in. A bit less noise next time someone runs a static analysis tool on the code.
commit 7967aea84b920d304b99fab60a612740854bd877 Author: Paul Floyd <pjfloyd@wanadoo.fr> Date: Sun Nov 8 08:00:36 2020 +0100 Bug 478716 - cppcheck detects potential leak in VEX/useful/smchash.c