add missing checks after memory allocation
add missing memset after memory allocation
This commit is contained in:
commit
5500db0898
@ -15,9 +15,8 @@ AC_CONFIG_AUX_DIR([libltdl/config])
|
|||||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
|
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
|
||||||
|
|
||||||
AM_PROG_LIBTOOL
|
AM_PROG_LIBTOOL
|
||||||
#fix for automake 1.12
|
# fix for automake 1.11 & 1.12
|
||||||
m4_pattern_allow([AM_PROG_AR])
|
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
||||||
AM_PROG_AR
|
|
||||||
|
|
||||||
LDFLAGS="$LDFLAGS -version-info 0:8:0"
|
LDFLAGS="$LDFLAGS -version-info 0:8:0"
|
||||||
|
|
||||||
|
84
libmbus.spec
Normal file
84
libmbus.spec
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#
|
||||||
|
# spec file for package libmbus
|
||||||
|
#
|
||||||
|
# Copyright (c) 2010-2013, Raditex Control AB
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# rSCADA
|
||||||
|
# http://www.rSCADA.se
|
||||||
|
# info@rscada.se
|
||||||
|
#
|
||||||
|
|
||||||
|
Summary: Open source M-bus (Meter-Bus) library
|
||||||
|
Name: libmbus
|
||||||
|
Version: 0.8.0
|
||||||
|
Release: 1
|
||||||
|
Source: http://www.rscada.se/public-dist/%{name}-%{version}.tar.gz
|
||||||
|
URL: http://www.rscada.se/libmbus/
|
||||||
|
License: BSD
|
||||||
|
Vendor: Raditex Control AB
|
||||||
|
Packager: Stefan Wahren <info@lategoodbye.de>
|
||||||
|
Group: Development/Languages/C and C++
|
||||||
|
BuildRoot: {_tmppath}/%{name}-%{version}-build
|
||||||
|
AutoReqProv: on
|
||||||
|
|
||||||
|
%description
|
||||||
|
libmbus: M-bus Library from Raditex Control (http://www.rscada.se)
|
||||||
|
|
||||||
|
libmbus is an open source library for the M-bus (Meter-Bus) protocol.
|
||||||
|
The Meter-Bus is a standard for reading out meter data from electricity meters,
|
||||||
|
heat meters, gas meters, etc. The M-bus standard deals with both the electrical
|
||||||
|
signals on the M-Bus, and the protocol and data format used in transmissions
|
||||||
|
on the M-Bus. The role of libmbus is to decode/encode M-bus data, and to handle
|
||||||
|
the communication with M-Bus devices.
|
||||||
|
|
||||||
|
For more information see http://www.rscada.se/libmbus
|
||||||
|
|
||||||
|
%package devel
|
||||||
|
License: BSD
|
||||||
|
Summary: Development libraries and header files for using the M-bus library
|
||||||
|
Group: Development/Libraries/C and C++
|
||||||
|
AutoReqProv: on
|
||||||
|
Requires: %{name} = %{version}
|
||||||
|
|
||||||
|
%description devel
|
||||||
|
This package contains all necessary include files and libraries needed
|
||||||
|
to compile and link applications which use the M-bus (Meter-Bus) library.
|
||||||
|
|
||||||
|
%prep -q
|
||||||
|
%setup -q
|
||||||
|
# workaround to get it's build
|
||||||
|
autoreconf
|
||||||
|
|
||||||
|
%build
|
||||||
|
./configure --prefix=/usr
|
||||||
|
make
|
||||||
|
|
||||||
|
%install
|
||||||
|
rm -Rf "%buildroot"
|
||||||
|
mkdir "%buildroot"
|
||||||
|
make install DESTDIR="%buildroot"
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf "%buildroot"
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr (-,root,root)
|
||||||
|
%doc COPYING README
|
||||||
|
%{_bindir}/mbus-serial-*
|
||||||
|
%{_bindir}/mbus-tcp-*
|
||||||
|
%{_libdir}/libmbus.so*
|
||||||
|
# man pages doesn't exist in this version
|
||||||
|
# %{_mandir}/man1/libmbus.1
|
||||||
|
# %{_mandir}/man1/mbus-*
|
||||||
|
|
||||||
|
%files devel
|
||||||
|
%defattr (-,root,root)
|
||||||
|
%{_includedir}/mbus
|
||||||
|
%{_libdir}/libmbus.a
|
||||||
|
%{_libdir}/libmbus.la
|
||||||
|
%{_libdir}/pkgconfig/libmbus.pc
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Fri Mar 29 2013 Stefan Wahren <info@lategoodbye.de> - 0.8.0-1
|
||||||
|
- Initial package based on the last official release
|
@ -1147,6 +1147,13 @@ mbus_parse_fixed_record(char status_byte, char medium_unit, u_char *data)
|
|||||||
/* shared/static memory - get own copy */
|
/* shared/static memory - get own copy */
|
||||||
record->function_medium = strdup(mbus_data_fixed_function((int)status_byte)); /* stored / actual */
|
record->function_medium = strdup(mbus_data_fixed_function((int)status_byte)); /* stored / actual */
|
||||||
|
|
||||||
|
if (record->function_medium == NULL)
|
||||||
|
{
|
||||||
|
MBUS_ERROR("%s: memory allocation error\n", __PRETTY_FUNCTION__);
|
||||||
|
mbus_record_free(record);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
long value = 0;
|
long value = 0;
|
||||||
if ((status_byte & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD)
|
if ((status_byte & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD)
|
||||||
{
|
{
|
||||||
@ -1203,6 +1210,13 @@ mbus_parse_variable_record(mbus_data_record *data)
|
|||||||
record->function_medium = strdup("Manufacturer specific");
|
record->function_medium = strdup("Manufacturer specific");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (record->function_medium == NULL)
|
||||||
|
{
|
||||||
|
MBUS_ERROR("%s: memory allocation error\n", __PRETTY_FUNCTION__);
|
||||||
|
mbus_record_free(record);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* parsing of data not implemented yet
|
/* parsing of data not implemented yet
|
||||||
manufacturer specific data structures to end of user data */
|
manufacturer specific data structures to end of user data */
|
||||||
|
|
||||||
@ -1228,6 +1242,14 @@ mbus_parse_variable_record(mbus_data_record *data)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
record->function_medium = strdup(mbus_data_record_function(data));
|
record->function_medium = strdup(mbus_data_record_function(data));
|
||||||
|
|
||||||
|
if (record->function_medium == NULL)
|
||||||
|
{
|
||||||
|
MBUS_ERROR("%s: memory allocation error\n", __PRETTY_FUNCTION__);
|
||||||
|
mbus_record_free(record);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
MBUS_DEBUG("record->function_medium = %s \n", record->function_medium);
|
MBUS_DEBUG("record->function_medium = %s \n", record->function_medium);
|
||||||
|
|
||||||
if (mbus_variable_value_decode(data, &value_out_real, &value_out_str, &value_out_str_size) != 0)
|
if (mbus_variable_value_decode(data, &value_out_real, &value_out_str, &value_out_str_size) != 0)
|
||||||
|
@ -3827,6 +3827,10 @@ mbus_frame_data_new()
|
|||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(data, 0, sizeof(mbus_frame_data));
|
||||||
|
|
||||||
|
data->data_var.data = NULL;
|
||||||
data->data_var.record = NULL;
|
data->data_var.record = NULL;
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user