Hi Sigrok Developers,

I noticed pulseview crashing when opening session files (definitely on
the command line and I think when using File->Open). Seems the
sequence of events causes File::create to clobber the existing
_sr_session global when opening a session file (at least on my Debian
Jessie setup).

Attached patch changes that temporary session to be a temporary
variable rather than the global session (more details in patch commit
text).

Thanks for all your hard work on sigrok!


Angus
>From 9cfb1569d8ee25f2c0df6893c0e895719e535658 Mon Sep 17 00:00:00 2001
From: Angus Gratton <[email protected]>
Date: Wed, 8 Oct 2014 09:35:23 +1100
Subject: [PATCH] Fix double-free issue in File::create

Triggered when opening a file from the command line.

During startup Sigsession::set_default_device calls Device::use which
loads a global _sr_session, then as part of file loading the
File::create method is called which treats _sr_session as a temp
variable (loaded then immediately released), finally a Device::release
releases the (differently allocated) global _sr_session again causing
the double free.

Given File::create is only using the sigrok session temporarily within
its function scope, this change gives it its own temporary session
instance.
---
 pv/device/file.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/pv/device/file.cpp b/pv/device/file.cpp
index e82c5ec..368276a 100644
--- a/pv/device/file.cpp
+++ b/pv/device/file.cpp
@@ -56,10 +56,11 @@ map<string, string> File::get_device_info() const
 
 File* File::create(const string &name)
 {
-	if (sr_session_load(name.c_str(), &SigSession::_sr_session) == SR_OK) {
+	struct sr_session *temp_session;
+	if (sr_session_load(name.c_str(), &temp_session) == SR_OK) {
 		GSList *devlist = NULL;
-		sr_session_dev_list(SigSession::_sr_session, &devlist);
-		sr_session_destroy(SigSession::_sr_session);
+		sr_session_dev_list(temp_session, &devlist);
+		sr_session_destroy(temp_session);
 
 		if (devlist) {
 			sr_dev_inst *const sdi = (sr_dev_inst*)devlist->data;
-- 
2.1.0

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to