Skip to content

Commit

Permalink
check command leak
Browse files Browse the repository at this point in the history
  • Loading branch information
well-mannered-goat committed Jan 20, 2025
1 parent eb790ca commit c7ce6db
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 12 deletions.
22 changes: 12 additions & 10 deletions librz/core/casm.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ RZ_API RzCmdStatus rz_core_asm_plugins_print(RZ_NONNULL RZ_BORROW RzCore *core,
}

RZ_API RzCmdStatus rz_core_cpu_descs_print(RZ_NONNULL RzCore *core, RZ_NONNULL const char *plugin) {
rz_return_val_if_fail(core && plugin, RZ_CMD_STATUS_ERROR);
rz_return_val_if_fail(core && plugin && core->rasm, RZ_CMD_STATUS_ERROR);
RzAsm *a = core->rasm;
RzIterator *iter = ht_sp_as_iter(a->plugins);
RzList *plugin_list = rz_list_new_from_iterator(iter);
Expand All @@ -232,20 +232,22 @@ RZ_API RzCmdStatus rz_core_cpu_descs_print(RZ_NONNULL RzCore *core, RZ_NONNULL c
RzListIter *it;
RzAsmPlugin *ap;
rz_list_foreach (plugin_list, it, ap) {
if (ap->cpus && !strcmp(plugin, ap->name)) {
if (ap->cpus && RZ_STR_EQ(plugin, ap->name)) {
char **desc = ap->get_cpu_desc();
if (desc) {
for (size_t i = 0; desc[i] != NULL; i += 2) {
rz_cons_printf("%-15s %s", desc[i], desc[i + 1]);
rz_cons_newline();
}
break;
} else {
if (!desc) {
rz_iterator_free(iter);
rz_list_free(plugin_list);
return RZ_CMD_STATUS_ERROR;
}
for (size_t i = 0; desc[i] != NULL; i += 2) {
rz_cons_printf("%-15s %s", desc[i], desc[i + 1]);
rz_cons_newline();
}
break;
}
}

rz_iterator_free(iter);
rz_list_free(plugin_list);
return RZ_CMD_STATUS_OK;
}

Expand Down
4 changes: 2 additions & 2 deletions librz/core/cmd_descs/cmd_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2398,15 +2398,15 @@ commands:
summary: List all asm/analysis plugins (e asm.arch=?)
subcommands:
- name: aL
summary: List all asm/analysis plugins (e asm.arch=?) or details of cpu for a plugin
summary: List all asm/analysis plugins (e asm.arch=?) or CPU details for a plugin.
cname: list_plugins
args: []
type: RZ_CMD_DESC_TYPE_ARGV_STATE
modes:
- RZ_OUTPUT_MODE_STANDARD
- RZ_OUTPUT_MODE_JSON
- name: aLc
summary: Show details of CPU for a specific plugin
summary: Show CPU details for a specific plugin.
cname: list_cpu_details
args:
- name: plugin_name
Expand Down
61 changes: 61 additions & 0 deletions test/db/cmd/cmd_aL
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ FILE==
CMDS=<<EOF
aLc mips
aLc xtensa
aLc arm
aLc avr
aLc m680x
aLc m68k
aLc pic
aLc ppc
aLc sparc
aLc tms320
aLc tricore
EOF
EXPECT=<<EOF
mips3 MIPS III architecture.
Expand Down Expand Up @@ -113,6 +122,58 @@ nofloat Special MIPS configuration to disable support for floating-point
esp32 Xtensa microcontroller with Wi-Fi and Bluetooth capabilities
esp32s2 Xtensa microcontroller with Wi-Fi and USB OTG support
esp8266 Xtensa microcontroller with Wi-Fi support
v8 ARMv8 version
cortexm ARM Cortex-M family
arm1176 ARM1176JZ(F)-S processor, ARMv6 version
cortexA72 ARM Cortex-A72 processor, ARMv8-A version
cortexA8 ARM Cortex-A8, ARMv7-A version
ATmega8 8-bit AVR microcontroller with 8KB Flash, 1KB SRAM
ATmega1280 8-bit AVR microcontroller with 128KB Flash, 8KB SRAM
ATmega1281 8-bit AVR microcontroller with 128KB Flash, 8KB SRAM
ATmega16 8-bit AVR microcontroller with 16KB Flash, 1KB SRAM
ATmega168 8-bit AVR microcontroller with 16KB Flash, 1KB SRAMs
ATmega2560 8-bit AVR microcontroller with 256KB Flash, 8KB SRAM
ATmega2561 8-bit AVR microcontroller with 256KB Flash, 8KB SRAM
ATmega328p 8-bit AVR microcontroller with 32KB Flash, 2KB SRAM
ATmega32u4 8-bit AVR microcontroller with 32KB Flash, 2.5KB SRAM
ATmega48 8-bit AVR microcontroller with 4KB Flash, 512B SRAM
ATmega640 8-bit AVR microcontroller with 64KB Flash, 8KB SRAM
ATmega88 8-bit AVR microcontroller with 8KB Flash, 1KB SRAM
ATxmega128a4u 8-bit AVR microcontroller with 128KB Flash, 8KB SRAM
ATTiny48 8-bit AVR microcontroller with 4KB Flash, 256B SRAM
ATTiny88 8-bit AVR microcontroller with 8KB Flash, 512B SRAM
6800 Motorola 6800: 8-bit microprocessor launched in 1974
6801 Motorola 6801: Enhanced version of the 6800 with additional features like on-chip RAM and timers.
6805 Motorola 68HC05: 8-bit microcontroller
6808 Motorola 6808: Variant of the 6800 microprocessor
6809 Motorola 6809: Advanced 8-bit microprocessor
6811 Motorola 68HC11: 8-bit microcontroller (also abbreviated as 6811 or HC11)
cpu12 Motorola 68HC12: 16-bit microcontroller (also abbreviated as 6812 or HC12)
6301 Hitachi 6301: 8-bit microcontroller, CMOS version of 6800
6309 Hitachi 6309: CMOS version of 6809
hcs08 Freescale HCS08: 8-bit microcontroller family
68000 Motorola 68000: 16/32-bit CISC microprocessor
68010 Motorola 68010: 16/32-bit microprocessors. Successor to Motoroloa 68000
68020 Motorola 68020: 32-bit microprocessor with added instructions and additional addressing modes
68030 Motorola 68030: Enhanced 32-bit microprocessor with integrated MMU
68040 Motorola 68040: High-performance 32-bit microprocessor with integrated FPU
68060 Motorola 68060: 32-bit microprocessor, highest performer in m68k series
pic18 PIC18: High-performance 8-bit microcontroller family
pic16 PIC16: Mid-range 8-bit microcontroller family
pic14 PIC14: 14-bit instruction set microcontroller family
highend Alias for PIC18
midrange Alias for PIC16
baseline Alias for PIC14
ppc Generic PowerPC CPU
vle PowerPC with Variable Length Encoding extension
ps PowerPC with Paired Single SIMD extension
qpx PowerPC with Quad Processing eXtensions
v9 SPARC V9: 64-bit RISC architecture specification
c54x Texas Instruments TMS320C54x DSP family
c55x Texas Instruments TMS320C55x DSP family
c55x+ Texas Instruments TMS320C55x+ DSP family
c64x Texas Instruments TMS320C64x DSP family
tricore Generic TriCore CPU family by Infineon
EOF
RUN

0 comments on commit c7ce6db

Please sign in to comment.