Revision: 6994 http://playerstage.svn.sourceforge.net/playerstage/?rev=6994&view=rev Author: thjc Date: 2008-08-30 02:19:04 +0000 (Sat, 30 Aug 2008)
Log Message: ----------- Applied [ 1957498 ] Fixes for segfaults on the InsideM300 RFID driver Modified Paths: -------------- code/player/branches/release-2-1-patches/server/drivers/rfid/insideM300.cc Modified: code/player/branches/release-2-1-patches/server/drivers/rfid/insideM300.cc =================================================================== --- code/player/branches/release-2-1-patches/server/drivers/rfid/insideM300.cc 2008-08-30 02:14:03 UTC (rev 6993) +++ code/player/branches/release-2-1-patches/server/drivers/rfid/insideM300.cc 2008-08-30 02:19:04 UTC (rev 6994) @@ -22,6 +22,7 @@ Author: Radu Bogdan Rusu Date: 25 Jan 2006 CVS: $Id$ + Fixes by Alexis Maldonado <maldonad //at// cs.tum.edu>. April/2008. */ /** @ingroup drivers */ @@ -225,7 +226,6 @@ // Destructor. InsideM300::~InsideM300() { - free(Data.tags); } //////////////////////////////////////////////////////////////////////////////// @@ -379,7 +379,15 @@ // Close the serial port tcsetattr (this->fd, TCSANOW, &this->initial_options); close (this->fd); + + for (unsigned int i=0; i != allocated_tags; ++i) { + delete [] Data.tags[i].guid; + } + free(Data.tags); + Data.tags=NULL; + allocated_tags=0; + PLAYER_MSG0 (1, "> InsideM300 driver shutting down... [done]"); return (0); } @@ -459,7 +467,7 @@ // RefreshData function void InsideM300::RefreshData () { - memset (&this->Data, 0, sizeof (player_rfid_data_t)); + memset (&this->Data, 0, sizeof (Data)); // Get the time at which we started reading // This will be a pretty good estimate of when the phenomena occured @@ -680,10 +688,12 @@ if (this->Data.tags_count >= this->allocated_tags) { this->allocated_tags = this->Data.tags_count+1; - this->Data.tags = (player_rfid_tag_t*)realloc(this->Data.tags,sizeof(this->Data.tags[0])*this->allocated_tags); + this->Data.tags = (player_rfid_tag_t*)realloc(this->Data.tags,sizeof(player_rfid_tag_t)*this->allocated_tags); + this->Data.tags[this->Data.tags_count].guid_count = 8; + this->Data.tags[this->Data.tags_count].guid=new char[8]; + } this->Data.tags[this->Data.tags_count].type = chipAnswer[1]; - this->Data.tags[this->Data.tags_count].guid_count = 8; int j; for (j = 0; j < 8; j++) this->Data.tags[this->Data.tags_count].guid[j] = @@ -750,6 +760,7 @@ chipMask = chipAnswer[2]; + switch (iStatus) { case STATUS_OK: @@ -760,13 +771,15 @@ if (this->Data.tags_count >= this->allocated_tags) { this->allocated_tags = this->Data.tags_count+1; - this->Data.tags = (player_rfid_tag_t*)realloc(this->Data.tags,sizeof(this->Data.tags[0])*this->allocated_tags); + this->Data.tags = (player_rfid_tag_t*)realloc(this->Data.tags,sizeof(player_rfid_tag_t)*this->allocated_tags); + this->Data.tags[this->Data.tags_count].guid_count = 8; + this->Data.tags[this->Data.tags_count].guid=new char[8]; } this->Data.tags[this->Data.tags_count].type = chipAnswer[1]; - this->Data.tags[this->Data.tags_count].guid_count = 8; int j; for (j = 0; j < 8; j++) this->Data.tags[this->Data.tags_count].guid[j] = chipAnswer [9-j]; + this->Data.tags_count++; break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit