Skip to content

Commit b0429be

Browse files
committed
Fix MacOSX Support
1 parent a75000b commit b0429be

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

dmidecode.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5695,7 +5695,7 @@ static u8 *dmi_table_get(off_t base, u32 *len, u16 num, u32 ver,
56955695
if (service == MACH_PORT_NULL)
56965696
{
56975697
fprintf(stderr, "AppleSMBIOS service is unreachable, sorry.\n");
5698-
return;
5698+
return NULL;
56995699
}
57005700

57015701
if (kIOReturnSuccess != IORegistryEntryCreateCFProperties(service,
@@ -5704,25 +5704,25 @@ static u8 *dmi_table_get(off_t base, u32 *len, u16 num, u32 ver,
57045704
kNilOptions))
57055705
{
57065706
fprintf(stderr, "No data in AppleSMBIOS IOService, sorry.\n");
5707-
return;
5707+
return NULL;
57085708
}
57095709

57105710
if (!CFDictionaryGetValueIfPresent(properties,
57115711
CFSTR( "SMBIOS"),
57125712
(const void **)&dataRef))
57135713
{
57145714
fprintf(stderr, "SMBIOS property data is unreachable, sorry.\n");
5715-
return;
5715+
return NULL;
57165716
}
57175717

5718-
len = CFDataGetLength(dataRef);
5719-
if((buf = malloc(sizeof(u8) * len)) == NULL)
5718+
*len = CFDataGetLength(dataRef);
5719+
if ((buf = malloc(sizeof(u8) * (*len))) == NULL)
57205720
{
57215721
perror("malloc");
5722-
return;
5722+
return NULL;
57235723
}
57245724

5725-
CFDataGetBytes(dataRef, CFRangeMake(0, len), (UInt8*)buf);
5725+
CFDataGetBytes(dataRef, CFRangeMake(0, *len), (UInt8*)buf);
57265726

57275727
if (NULL != dataRef)
57285728
CFRelease(dataRef);
@@ -5743,7 +5743,7 @@ static u8 *dmi_table_get(off_t base, u32 *len, u16 num, u32 ver,
57435743
#endif
57445744

57455745
// read tables from file devmem file
5746-
if (!(flags & FLAG_READ_FROM_API) && (buf = mem_chunk(base, len, devmem)) == NULL)
5746+
if (!(flags & FLAG_READ_FROM_API) && (buf = mem_chunk(base, *len, devmem)) == NULL)
57475747
{
57485748
fprintf(stderr, "Failed to read table, sorry.\n");
57495749
#ifndef USE_MMAP

0 commit comments

Comments
 (0)