From: Michael Schroeder Date: Thu, 14 Jul 2011 09:37:01 +0000 (+0200) Subject: - swig bug: can't overload __str__ in perl, causes memory corruption as it tries... X-Git-Tag: BASE-SuSE-Code-12_1-Branch~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c4934b45d2b76cc445fe3915c0d7dbd00341119b;p=platform%2Fupstream%2Flibsolv.git - swig bug: can't overload __str__ in perl, causes memory corruption as it tries to stringify freed objects --- diff --git a/bindings/solv.i b/bindings/solv.i index c029cb4..63b9eab 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -679,16 +679,15 @@ typedef struct { return q; } - const char *str() { - return pool_job2str($self->pool, $self->how, $self->what, 0); - } - bool __eq__(Job *j) { return $self->pool == j->pool && $self->how == j->how && $self->what == j->what; } bool __ne__(Job *j) { return !Job___eq__($self, j); } +#if defined(SWIGPERL) + %rename("str") __str__; +#endif const char *__str__() { return pool_job2str($self->pool, $self->how, $self->what, 0); } @@ -782,6 +781,9 @@ typedef struct { %rename("to_s") __str__; %rename("inspect") __repr__; #endif +#if defined(SWIGPERL) + %rename("str") __str__; +#endif %newobject __str__; const char *__str__() { const char *str; @@ -1230,6 +1232,9 @@ typedef struct { bool __ne__(Repo *repo) { return $self != repo; } +#if defined(SWIGPERL) + %rename("str") __str__; +#endif %newobject __str__; const char *__str__() { char buf[20]; @@ -1554,6 +1559,9 @@ typedef struct { bool __ne__(Dep *s) { return !Dep___eq__($self, s); } +#if defined(SWIGPERL) + %rename("str") __str__; +#endif const char *__str__() { return pool_dep2str($self->pool, $self->id); } @@ -1678,6 +1686,9 @@ typedef struct { bool __ne__(XSolvable *s) { return !XSolvable___eq__($self, s); } +#if defined(SWIGPERL) + %rename("str") __str__; +#endif const char *__str__() { return pool_solvid2str($self->pool, $self->id); } diff --git a/examples/p5solv b/examples/p5solv index 08c96bc..804b864 100755 --- a/examples/p5solv +++ b/examples/p5solv @@ -123,14 +123,14 @@ sub usecachedrepo { return undef if sysread($f, $fextcookie, 32) != 32; } sysseek($f, 0, Fcntl::SEEK_SET); - $f = solv::xfopen_dup(undef, fileno($f)); + my $fd = solv::xfopen_dup(undef, fileno($f)); my $flags = $ext ? $solv::Repo::REPO_USE_LOADING|$solv::Repo::REPO_EXTEND_SOLVABLES : 0; $flags |= $solv::Repo::REPO_LOCALPOOL if $ext && $ext ne 'DL'; - if (!$self->{'handle'}->add_solv($f, $flags)) { - solv::xfclose($f); + if (!$self->{'handle'}->add_solv($fd, $flags)) { + solv::xfclose($fd); return undef; } - solv::xfclose($f); + solv::xfclose($fd); $self->{'cookie'} = $fcookie unless $ext; $self->{'extcookie'} = $fextcookie if $fextcookie; utime undef, undef, $f if $mark;