mirror of
https://github.com/radareorg/radare2.git
synced 2025-03-03 11:50:02 +00:00
Fix div by zero and help for $fl
This commit is contained in:
parent
2c5400e03e
commit
521458908b
@ -463,7 +463,7 @@ static int cmd_help(void *data, const char *input) {
|
||||
"$b", "", "block size",
|
||||
"$B", "", "base address (aligned lowest map address)",
|
||||
"$f", "", "jump fail address (e.g. jz 0x10 => next instruction)",
|
||||
"$fl", "", "flag length (size) at current address (fla; pD $l @ entry0)"
|
||||
"$fl", "", "flag length (size) at current address (fla; pD $l @ entry0)",
|
||||
"$F", "", "current function size",
|
||||
"$FB", "", "begin of function",
|
||||
"$Fb", "", "address of the current basic block",
|
||||
|
@ -16,7 +16,7 @@ static double get_px(ut8 x, const ut8 *data, ut64 size) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return (double) count / size;
|
||||
return size > 0? (double) count / size: 0;
|
||||
}
|
||||
|
||||
R_API double r_hash_entropy(const ut8 *data, ut64 size) {
|
||||
@ -24,8 +24,9 @@ R_API double r_hash_entropy(const ut8 *data, ut64 size) {
|
||||
double h = 0, px, log2 = log (2.0);
|
||||
for (x = 0; x < 256; x++) {
|
||||
px = get_px (x, data, size);
|
||||
if (px > 0)
|
||||
if (px > 0) {
|
||||
h += -px * (log (px) / log2);
|
||||
}
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user