Skip to content

Commit

Permalink
v0.7 fix stringbuf memory allocation leak
Browse files Browse the repository at this point in the history
  • Loading branch information
yurial committed Jul 24, 2012
1 parent a524300 commit a4679f7
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 19 deletions.
6 changes: 5 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
2012-07-24 Yuri Dyachenko <[email protected]>
Version 0.7 released
Fix bug with stringbuf memory allocation.

2012-07-23 Yuri Dyachenko <[email protected]>
Version 0.6 released
Fix bug with multithread syslog initialization
Fix bug with multithread syslog initialization.

2012-06-29 Yuri Dyachenko <[email protected]>
Version 0.5 released
Expand Down
20 changes: 10 additions & 10 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for syslogpp 0.6.
# Generated by GNU Autoconf 2.68 for syslogpp 0.7.
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
Expand Down Expand Up @@ -567,8 +567,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='syslogpp'
PACKAGE_TARNAME='syslogpp'
PACKAGE_VERSION='0.6'
PACKAGE_STRING='syslogpp 0.6'
PACKAGE_VERSION='0.7'
PACKAGE_STRING='syslogpp 0.7'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''

Expand Down Expand Up @@ -1299,7 +1299,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures syslogpp 0.6 to adapt to many kinds of systems.
\`configure' configures syslogpp 0.7 to adapt to many kinds of systems.

Usage: $0 [OPTION]... [VAR=VALUE]...

Expand Down Expand Up @@ -1369,7 +1369,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of syslogpp 0.6:";;
short | recursive ) echo "Configuration of syslogpp 0.7:";;
esac
cat <<\_ACEOF

Expand Down Expand Up @@ -1474,7 +1474,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
syslogpp configure 0.6
syslogpp configure 0.7
generated by GNU Autoconf 2.68

Copyright (C) 2010 Free Software Foundation, Inc.
Expand Down Expand Up @@ -1960,7 +1960,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by syslogpp $as_me 0.6, which was
It was created by syslogpp $as_me 0.7, which was
generated by GNU Autoconf 2.68. Invocation command line was

$ $0 $@
Expand Down Expand Up @@ -2775,7 +2775,7 @@ fi

# Define the identity of the package.
PACKAGE=syslogpp
VERSION=0.6
VERSION=0.7


cat >>confdefs.h <<_ACEOF
Expand Down Expand Up @@ -16071,7 +16071,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by syslogpp $as_me 0.6, which was
This file was extended by syslogpp $as_me 0.7, which was
generated by GNU Autoconf 2.68. Invocation command line was

CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -16137,7 +16137,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
syslogpp config.status 0.6
syslogpp config.status 0.7
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"

Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AC_INIT([syslogpp],[0.6])
AM_INIT_AUTOMAKE([syslogpp],[0.6])
AC_INIT([syslogpp],[0.7])
AM_INIT_AUTOMAKE([syslogpp],[0.7])
AC_CONFIG_MACRO_DIR([m4])
m4_include([m4/acx_pthread.m4])
: ${CXXFLAGS=""}
Expand Down
1 change: 1 addition & 0 deletions ebuild/Manifest
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ EBUILD libsyslogpp-0.3.ebuild 679 RMD160 46f1f9a1d96a9e721aa0fa3e238789ffd84662e
EBUILD libsyslogpp-0.4.ebuild 679 RMD160 46f1f9a1d96a9e721aa0fa3e238789ffd84662e3 SHA1 e68ff52566cae6d0c4776be69c8b25b6f397a5f2 SHA256 fcc945c5cbd66c9702d32b484254b14f7f1accbfb84c91fa8fdfd9d3edef7f3a
EBUILD libsyslogpp-0.5.ebuild 679 RMD160 46f1f9a1d96a9e721aa0fa3e238789ffd84662e3 SHA1 e68ff52566cae6d0c4776be69c8b25b6f397a5f2 SHA256 fcc945c5cbd66c9702d32b484254b14f7f1accbfb84c91fa8fdfd9d3edef7f3a
EBUILD libsyslogpp-0.6.ebuild 679 RMD160 46f1f9a1d96a9e721aa0fa3e238789ffd84662e3 SHA1 e68ff52566cae6d0c4776be69c8b25b6f397a5f2 SHA256 fcc945c5cbd66c9702d32b484254b14f7f1accbfb84c91fa8fdfd9d3edef7f3a
EBUILD libsyslogpp-0.7.ebuild 679 RMD160 46f1f9a1d96a9e721aa0fa3e238789ffd84662e3 SHA1 e68ff52566cae6d0c4776be69c8b25b6f397a5f2 SHA256 fcc945c5cbd66c9702d32b484254b14f7f1accbfb84c91fa8fdfd9d3edef7f3a
EBUILD libsyslogpp-9999.ebuild 679 RMD160 46f1f9a1d96a9e721aa0fa3e238789ffd84662e3 SHA1 e68ff52566cae6d0c4776be69c8b25b6f397a5f2 SHA256 fcc945c5cbd66c9702d32b484254b14f7f1accbfb84c91fa8fdfd9d3edef7f3a
MISC ChangeLog 573 RMD160 67bbfc19a70b171f38a3bd88c854db167ff0d415 SHA1 d718f197708e552b68b26de91577756d4ec2fa0a SHA256 2b8106be4cb0c528aa93c9760d951295b4e181d5a1defbc64f681612a858191f
1 change: 1 addition & 0 deletions ebuild/libsyslogpp-0.7.ebuild
6 changes: 4 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
CXXFLAGS+=-DHAVE_SYSLOG_H
LDLIBS+=-lsyslogpp
all: cerr clog std stream
all: cerr clog std stream loop
clean:
rm -f cerr clog std stream
rm -f cerr clog std stream loop
cerr: cerr.cpp
clog: clog.cpp
std: std.cpp
stream: stream.cpp
loop: loop.cpp

15 changes: 15 additions & 0 deletions examples/loop.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdlib.h>
#include <syslogpp.h>

int main()
{
syslog.open( NULL, LOG_PID, LOG_USER );
for (int i = 0; i < 1024*1024*1024; ++i)
{
syslog( LOG_DEBUG ) << "syslog stream interface " << i << std::endl;
}
syslog.close();
pause();
return EXIT_SUCCESS;
}

8 changes: 4 additions & 4 deletions src/syslogpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ m_prio = prio;

int syslogbuf::sync()
{
char* str = pbase();
if ( epptr() != str )
if ( in_avail() )
{
sputc( '\0' );
syslog( m_prio, "%s", str );
setp( str, str );
syslog( m_prio, "%s", gptr() );
seekoff( 0, std::ios_base::beg, std::ios_base::in | std::ios_base::out );
setg( pbase(), pbase(), pbase() );
}
return 0; //success
}
Expand Down

0 comments on commit a4679f7

Please sign in to comment.