Fixed various errors/warnings reported by cppcheck:

* memory leaks
* resource leaks
* added const's to getters
* removed a few reundant conditions


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35433 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Artur Wyszynski 2010-02-08 22:50:38 +00:00
parent c0cd8cf199
commit cee04e8074
54 changed files with 153 additions and 126 deletions

View File

@ -17,50 +17,50 @@ class BGLRenderer
{
// Private unimplemented copy constructors
BGLRenderer(const BGLRenderer &);
BGLRenderer & operator=(const BGLRenderer &);
BGLRenderer(const BGLRenderer &);
BGLRenderer & operator=(const BGLRenderer &);
public:
BGLRenderer(BGLView *view, ulong bgl_options, BGLDispatcher *dispatcher);
virtual ~BGLRenderer();
BGLRenderer(BGLView *view, ulong bgl_options, BGLDispatcher *dispatcher);
virtual ~BGLRenderer();
void Acquire();
void Release();
void Acquire();
void Release();
virtual void LockGL();
virtual void UnlockGL();
virtual void SwapBuffers(bool VSync = false);
virtual void Draw(BRect updateRect);
virtual status_t CopyPixelsOut(BPoint source, BBitmap *dest);
virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest);
virtual status_t CopyPixelsOut(BPoint source, BBitmap *dest);
virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest);
virtual void FrameResized(float width, float height);
virtual void DirectConnected(direct_buffer_info *info);
virtual void EnableDirectMode(bool enabled);
virtual void DirectConnected(direct_buffer_info *info);
virtual void EnableDirectMode(bool enabled);
inline int32 ReferenceCount() { return fRefCount; };
inline ulong Options() { return fOptions; };
inline BGLView * GLView() { return fView; };
inline int32 ReferenceCount() const { return fRefCount; };
inline ulong Options() const { return fOptions; };
inline BGLView * GLView() { return fView; };
inline BGLDispatcher * GLDispatcher() { return fDispatcher; };
private:
friend class GLRendererRoster;
virtual status_t _Reserved_Renderer_0(int32, void *);
virtual status_t _Reserved_Renderer_1(int32, void *);
virtual status_t _Reserved_Renderer_2(int32, void *);
virtual status_t _Reserved_Renderer_3(int32, void *);
virtual status_t _Reserved_Renderer_4(int32, void *);
virtual status_t _Reserved_Renderer_0(int32, void *);
virtual status_t _Reserved_Renderer_1(int32, void *);
virtual status_t _Reserved_Renderer_2(int32, void *);
virtual status_t _Reserved_Renderer_3(int32, void *);
virtual status_t _Reserved_Renderer_4(int32, void *);
volatile int32 fRefCount; // How much we're still usefull?
BGLView * fView; // Never forget who is the boss!
ulong fOptions; // Keep that tune in memory
BGLDispatcher * fDispatcher; // Our personal OpenGL API call dispatcher
volatile int32 fRefCount; // How much we're still usefull?
BGLView* fView; // Never forget who is the boss!
ulong fOptions; // Keep that tune in memory
BGLDispatcher* fDispatcher; // Our personal OpenGL API call dispatcher
GLRendererRoster *fOwningRoster;
renderer_id fID;
GLRendererRoster* fOwningRoster;
renderer_id fID;
};
extern "C" _EXPORT BGLRenderer * instantiate_gl_renderer(BGLView *view, ulong options, BGLDispatcher *dispatcher);
@ -68,7 +68,3 @@ extern "C" _EXPORT BGLRenderer * instantiate_gl_renderer(BGLView *view, ulong op
#endif // GLRENDERER_H

View File

@ -27,7 +27,7 @@ class LinkReceiver {
virtual ~LinkReceiver(void);
void SetPort(port_id port);
port_id Port(void) { return fReceivePort; }
port_id Port(void) const { return fReceivePort; }
status_t GetNextMessage(int32& code, bigtime_t timeout = B_INFINITE_TIMEOUT);
bool HasMessages() const;

View File

@ -22,7 +22,7 @@ class LinkSender {
virtual ~LinkSender(void);
void SetPort(port_id port);
port_id Port() { return fPort; }
port_id Port() const { return fPort; }
status_t StartMessage(int32 code, size_t minSize = 0);
void CancelMessage(void);

View File

@ -77,10 +77,10 @@ public:
throw fError;
}
status_t Status() { return fError >= B_OK ? B_OK : fError; };
status_t Status() const { return fError >= B_OK ? B_OK : fError; };
void SetSwap(bool yesNo) { fSwap = yesNo; };
bool IsSwapping() { return fSwap; };
bool IsSwapping() const { return fSwap; };
private:
BDataIO *fStream;

View File

@ -71,7 +71,7 @@ class Autolock {
}
bool
IsLocked()
IsLocked() const
{
return fStatus == B_OK;
}

View File

@ -82,12 +82,12 @@ public:
return -1;
}
int CountItems()
int CountItems() const
{
return item_count;
}
bool IsEmpty()
bool IsEmpty() const
{
return item_count == 0;
}

View File

@ -44,16 +44,16 @@ public:
BPath& Path() { return fSettingsPath; }
// General screen saver settings
int32 TimeFlags() { return fTimeFlags; }
bigtime_t BlankTime() { return fBlankTime; }
bigtime_t StandByTime() { return fStandByTime; }
bigtime_t SuspendTime() { return fSuspendTime; }
bigtime_t OffTime() { return fOffTime; }
int32 TimeFlags() const { return fTimeFlags; }
bigtime_t BlankTime() const { return fBlankTime; }
bigtime_t StandByTime() const { return fStandByTime; }
bigtime_t SuspendTime() const { return fSuspendTime; }
bigtime_t OffTime() const { return fOffTime; }
screen_corner BlankCorner() { return fBlankCorner; }
screen_corner NeverBlankCorner() { return fNeverBlankCorner; }
bool LockEnable() { return fLockEnabled; }
bigtime_t PasswordTime() { return fPasswordTime; }
screen_corner BlankCorner() const { return fBlankCorner; }
screen_corner NeverBlankCorner() const { return fNeverBlankCorner; }
bool LockEnable() const { return fLockEnabled; }
bigtime_t PasswordTime() const { return fPasswordTime; }
const char* Password() { return fPassword.String(); }
const char* LockMethod() { return fLockMethod.String(); }
bool IsNetworkPassword()
@ -93,8 +93,8 @@ public:
BMessage* stateMessage);
// ScreenSaver preferences settings
BRect WindowFrame() { return fWindowFrame; }
int32 WindowTab() { return fWindowTab; }
BRect WindowFrame() const { return fWindowFrame; }
int32 WindowTab() const { return fWindowTab; }
void SetWindowFrame(const BRect& frame)
{ fWindowFrame = frame; }

View File

@ -84,7 +84,7 @@ SET_CURSOR_SHAPE(uint16 width, uint16 height, uint16 hot_x,
scanlineSize = 4 * ((width + 31) / 32);
scanline = calloc(1, scanlineSize);
if (calloc == NULL)
if (scanline == NULL)
return B_ERROR;
FifoBeginWrite();

View File

@ -92,8 +92,10 @@ acpi_device_init_driver(device_node *node, void **cookie)
memset(device, 0, sizeof(*device));
if (AcpiGetHandle(NULL, (ACPI_STRING)path, &handle) != AE_OK)
if (AcpiGetHandle(NULL, (ACPI_STRING)path, &handle) != AE_OK) {
free(device);
return B_ENTRY_NOT_FOUND;
}
device->handle = handle;
device->path = strdup(path);

View File

@ -823,15 +823,20 @@ static BusLogic *create_cardinfo(int num, int iobase, int irq)
/* can't be sure of getting contig pages -- scale
stuff down so we can live in just one page */
bl->box_count = 4;
if(!(a = malloc(4096*2))) return NULL;
if(!(a = malloc(4096*2))) {
free(bl);
return NULL;
}
a = (uchar *) ((((uint32) a) & 0xFFFFF000) + 0x1000);
get_memory_map(a, 4096, entries, 2);
#else
bl->box_count = MAX_CCB_COUNT;
aid = create_area("bl_workspace", (void **)&a, B_ANY_KERNEL_ADDRESS, 4096*5,
B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA);
if(aid == B_ERROR || aid == B_BAD_VALUE || aid == B_NO_MEMORY)
if(aid == B_ERROR || aid == B_BAD_VALUE || aid == B_NO_MEMORY) {
free(bl);
return NULL;
}
get_memory_map(a, 4096*5, entries, 2);
#endif

View File

@ -124,8 +124,10 @@ init_words(char *from)
if (fd < B_OK)
return fd;
/* lseek() seems to always return 0 from the kernel ??? */
if (fstat(fd, &st))
if (fstat(fd, &st)) {
close(fd);
return B_ERROR;
}
sz = (size_t)st.st_size;
// sz = (size_t)lseek(fd, 0, SEEK_END);
// dprintf("khangman: lseek(): %ld\n", sz);

View File

@ -1155,8 +1155,10 @@ hda_codec_new_audio_group(hda_codec* codec, uint32 audioGroupNodeID)
audioGroup->codec = codec;
audioGroup->multi = (hda_multi*)calloc(1,
sizeof(hda_multi));
if (audioGroup->multi == NULL)
if (audioGroup->multi == NULL) {
free(audioGroup);
return B_NO_MEMORY;
}
audioGroup->multi->group = audioGroup;
/* Parse all widgets in Audio Function Group */

View File

@ -104,6 +104,8 @@ public:
{
}
virtual ~AbstractLocker() {}
size_t AvailableBytes() const
{ return fBytes; }

View File

@ -134,8 +134,10 @@ status_t google_request_process(struct google_request *req)
fd = open(FAKE_INPUT, O_RDONLY, 0644);
if (fd < 0)
return -1;
if (fstat(fd, &st) < 0)
if (fstat(fd, &st) < 0) {
close(fd);
return -1;
}
cnx->datalen = st.st_size;
cnx->data = malloc(cnx->datalen);
if (!cnx->data)

View File

@ -2748,8 +2748,10 @@ ClientConnection::_CreateVolume(ClientVolume** _volume)
if (!volume)
return B_NO_MEMORY;
status_t error = volume->Init();
if (error != B_OK)
if (error != B_OK) {
delete volume;
return error;
}
// add it to the volume map
AutoLocker<VolumeMap> locker(fVolumes);

View File

@ -790,8 +790,10 @@ NetFSServer::_LoadSecurityContext(SecurityContext** _securityContext)
if (!securityContext)
return B_NO_MEMORY;
status_t error = securityContext->InitCheck();
if (error != B_OK)
if (error != B_OK) {
delete securityContext;
return error;
}
ObjectDeleter<SecurityContext> securityContextDeleter(securityContext);
// load from driver settings for the time being

View File

@ -796,7 +796,7 @@ PRINT(("VolumeManager::OpenQuery(%p, \"%s\", 0x%lx, %ld, %ld)\n", queryDomain, q
// allocate the handle
QueryHandle* queryHandle = new(std::nothrow) QueryHandle(remotePort,
remoteToken);
if (!handle)
if (!queryHandle)
return B_NO_MEMORY;
ObjectDeleter<QueryHandle> handleDeleter(queryHandle);

View File

@ -21,7 +21,7 @@
class PartitionLocker {
public:
PartitionLocker(partition_id partitionID);
~PartitionLocker();
virtual ~PartitionLocker();
bool IsLocked() const;
partition_id PartitionId() const;

View File

@ -21,7 +21,7 @@
class PartitionLocker {
public:
PartitionLocker(partition_id partitionID);
~PartitionLocker();
virtual ~PartitionLocker();
bool IsLocked() const;
partition_id PartitionId() const;

View File

@ -627,8 +627,11 @@ BPositionIO *outDestination, color_space fromspace, MSInfoHeader &msheader)
const color_map *pmap = NULL;
if (fromspace == B_CMAP8) {
pmap = system_colors();
if (!pmap)
if (!pmap) {
delete [] bmpRowData;
delete [] bitsRowData;
return B_ERROR;
}
}
while (rd == static_cast<ssize_t>(bitsRowBytes)) {

View File

@ -591,6 +591,7 @@ Table::TableRowsAdded(TableModel* model, int32 rowIndex, int32 count)
TableField* field = new(std::nothrow) TableField(i);
if (field == NULL) {
// TODO: Report error!
delete row;
return;
}

View File

@ -64,8 +64,10 @@ SetGradientCommand::Perform()
*fGradient = *fStyle->Gradient();
else {
fGradient = new (nothrow) Gradient(*fStyle->Gradient());
if (!fGradient)
if (!fGradient) {
delete clone;
return B_NO_MEMORY;
}
}
} else {
// the style didn't have a gradient set

View File

@ -24,18 +24,18 @@ class AreaLinkHeader {
AreaLinkHeader() { MakeEmpty(); fLock = B_NAME_NOT_FOUND; }
void SetAttachmentCount(uint32 size) { fAttachmentCount = size; }
uint32 GetAttachmentCount() { return fAttachmentCount; }
uint32 GetAttachmentCount() const { return fAttachmentCount; }
void SetAttachmentSize(uint32 size) { fAttachmentSize = size; }
uint32 GetAttachmentSize() { return fAttachmentSize; }
uint32 GetAttachmentSize() const { return fAttachmentSize; }
void AddAttachment(uint32 size) { fAttachmentSize += size; fAttachmentCount++; }
void SetLockSem(sem_id sem) { fLock = sem; }
sem_id GetLockSem() { return fLock; }
sem_id GetLockSem() const { return fLock; }
void MakeEmpty() { fAttachmentCount = 0; fAttachmentSize = 0; }
area_info GetInfo() { return fInfo; }
area_info GetInfo() const { return fInfo; }
void SetInfo(const area_info &newInfo) { fInfo = newInfo; }
private:
@ -61,8 +61,9 @@ AreaLink::AreaLink()
:fAttachList(new BList(0)),
fTarget(B_NAME_NOT_FOUND),
fAreaIsOk(false),
fHaveLock(false)
fHaveLock(false),
fBaseAddress(0),
fHeader(0)
{
}

View File

@ -16,10 +16,11 @@ BMessenger* _RetrieveBluetoothMessenger(void)
// Fix/review: leaking memory here
BMessenger* fMessenger = new BMessenger(BLUETOOTH_SIGNATURE);
if (fMessenger == NULL || !fMessenger->IsValid())
return NULL;
else
return fMessenger;
if (fMessenger == NULL || !fMessenger->IsValid()) {
delete fMessenger;
return NULL;
} else
return fMessenger;
}
@ -32,5 +33,5 @@ uint8 GetInquiryTime()
void SetInquiryTime(uint8 time)
{
((void)(time));
}

View File

@ -17,6 +17,7 @@
BListItem::BListItem(uint32 level, bool expanded)
:
fTop(0.0),
fTemporaryList(0),
fWidth(0),
fHeight(0),
fLevel(level),

View File

@ -550,8 +550,10 @@ _BPictureExtent_::Unflatten(BDataIO *stream)
for (int32 i = 0; i < count; i++) {
BPicture* picture = new BPicture;
status_t status = picture->Unflatten(stream);
if (status < B_OK)
if (status < B_OK) {
delete picture;
return status;
}
AddPicture(picture);
}

View File

@ -92,7 +92,8 @@ BCollator::BCollator(BCollatorAddOn *collator, int8 strength,
BCollator::BCollator(BMessage *archive)
: BArchivable(archive),
fCollator(NULL),
fCollatorImage(B_ERROR)
fCollatorImage(B_ERROR),
fIgnorePunctuation(true)
{
#if HAIKU_TARGET_PLATFORM_HAIKU
int32 data;

View File

@ -1016,6 +1016,9 @@ BGenericNumberFormat::BGenericNumberFormat()
// destructor
BGenericNumberFormat::~BGenericNumberFormat()
{
delete fSignSymbols;
delete fMantissaSignSymbols;
delete fExponentSignSymbols;
}
// FormatInteger

View File

@ -93,8 +93,7 @@ BLanguage::BLanguage(const char *language)
BLanguage::~BLanguage()
{
if (fICULocale != NULL)
delete fICULocale;
delete fICULocale;
for (int32 i = B_NUM_LANGUAGE_STRINGS;i-- > 0;)
free(fStrings[i]);

View File

@ -189,6 +189,7 @@ BNumberFormatParameters::operator=(const BNumberFormatParameters &other)
fUseBasePrefix = other.fUseBasePrefix;
fMinimalIntegerDigits = other.fMinimalIntegerDigits;
fFlags = other.fFlags;
fUseZeroPadding = other.fUseZeroPadding;
return *this;
}

View File

@ -476,9 +476,7 @@ BMailChainRunner::get_messages(BStringList *list)
if (err == B_MAIL_DISCARD)
entry->Remove();
if (file != NULL)
delete file;
delete file;
delete entry;
delete headers;
delete folder;

View File

@ -419,8 +419,7 @@ BAttributedMailAttachment::~BAttributedMailAttachment() {
status_t BAttributedMailAttachment::Initialize()
{
// _data & _attributes_attach will be deleted by the container
if (fContainer != NULL)
delete fContainer;
delete fContainer;
fContainer = new BMIMEMultipartMailContainer("++++++BFile++++++");
@ -639,8 +638,10 @@ status_t BAttributedMailAttachment::RenderToRFC822(BPositionIO *render_to) {
io->Write(&swapped,sizeof(int64));
void *allocd = malloc(dataLen);
if (allocd == NULL)
if (allocd == NULL) {
delete io;
return B_NO_MEMORY;
}
memcpy(allocd,data,dataLen);
swap_data(type, allocd, dataLen, B_SWAP_HOST_TO_BENDIAN);
io->Write(allocd,dataLen);

View File

@ -41,8 +41,7 @@ BMailChain::BMailChain(BMessage* settings)
BMailChain::~BMailChain() {
if (meta_data != NULL)
delete meta_data;
delete meta_data;
for (int32 i = 0; filter_settings.ItemAt(i); i++)
delete (BMessage *)filter_settings.ItemAt(i);
@ -53,8 +52,7 @@ BMailChain::~BMailChain() {
status_t BMailChain::Load(BMessage* settings)
{
if (meta_data != NULL)
delete meta_data;
delete meta_data;
meta_data = new BMessage;
if (settings->HasMessage("meta_data"))

View File

@ -96,8 +96,7 @@ BEmailMessage::BEmailMessage(entry_ref *ref, uint32 defaultCharSet)
BEmailMessage::~BEmailMessage()
{
if (_bcc != NULL)
free(_bcc);
free(_bcc);
delete _body;
delete fData;
@ -327,8 +326,7 @@ void BEmailMessage::SetCC(const char *cc, uint32 charset, mail_encoding encoding
}
void BEmailMessage::SetBCC(const char *bcc) {
if (_bcc != NULL)
free(_bcc);
free(_bcc);
_bcc = strdup(bcc);
}

View File

@ -308,8 +308,8 @@ BBufferConsumer::SetOutputBuffersFor(const media_source &source,
free(command);
if (rv == B_OK) {
if (fDeleteBufferGroup) // XXX will leak memory if port write failed
delete fDeleteBufferGroup;
// XXX will leak memory if port write failed
delete fDeleteBufferGroup;
fDeleteBufferGroup = will_reclaim ? NULL : group;
}
return rv;

View File

@ -1990,8 +1990,10 @@ BDiscreteParameter::AddItem(int32 value, const char* name)
int32* valueCopy = new int32(value);
char* nameCopy = strndup(name, 255);
if (name != NULL && nameCopy == NULL)
if (name != NULL && nameCopy == NULL) {
delete valueCopy;
return B_NO_MEMORY;
}
if (!fValues->AddItem(valueCopy) || !fSelections->AddItem(nameCopy))
return B_NO_MEMORY;

View File

@ -441,8 +441,7 @@ BAppFileInfo::GetSupportedTypes(BMessage *types) const
if (error == B_OK)
error = types->Unflatten((const char*)buffer);
// clean up
if (buffer)
free(buffer);
free(buffer);
return error;
}
@ -517,8 +516,7 @@ BAppFileInfo::SetSupportedTypes(const BMessage *types, bool syncAll)
buffer, size);
}
// clean up
if (buffer)
delete[] buffer;
delete[] buffer;
} else
error = _RemoveData(kSupportedTypesAttribute, B_MESSAGE_TYPE);
// update the MIME database, if the app signature is installed

View File

@ -976,13 +976,17 @@ BPathMonitor::StartWatching(const char* path, uint32 flags, BMessenger target)
if (handler == NULL)
return B_NO_MEMORY;
status = handler->InitCheck();
if (status < B_OK)
if (status < B_OK) {
delete handler;
return status;
}
if (watcher == NULL) {
watcher = new (nothrow) BPrivate::Watcher;
if (watcher == NULL)
if (watcher == NULL) {
delete handler;
return B_NO_MEMORY;
}
sWatchers[target] = watcher;
}

View File

@ -41,7 +41,7 @@ private:
};
#if __GNUC__ > 2
#if __GNUC__ > 3
BStatable::~BStatable()
{
}

View File

@ -425,8 +425,7 @@ BDiskDevice::_GetData(partition_id id, bool deviceOnly, size_t neededSize,
(user_disk_device_data*)buffer, bufferSize, &neededSize);
if (error == B_BUFFER_OVERFLOW) {
// buffer to small re-allocate it
if (buffer)
free(buffer);
free(buffer);
buffer = malloc(neededSize);
@ -440,7 +439,7 @@ BDiskDevice::_GetData(partition_id id, bool deviceOnly, size_t neededSize,
// set result / cleanup on error
if (error == B_OK)
*data = (user_disk_device_data*)buffer;
else if (buffer)
else
free(buffer);
return error;

View File

@ -36,8 +36,7 @@ BDiskDeviceList::BDiskDeviceList(bool useOwnLocker)
*/
BDiskDeviceList::~BDiskDeviceList()
{
if (fLocker)
delete fLocker;
delete fLocker;
}
// MessageReceived

View File

@ -182,12 +182,9 @@ PartitioningDialog::_Init(BDiskScannerParameterEditor *editor)
delete okMessage;
if (!cancelButton && cancelMessage)
delete cancelMessage;
if (okButton)
delete okButton;
if (cancelButton)
delete cancelButton;
if (mainView)
delete mainView;
delete okButton;
delete cancelButton;
delete mainView;
}
}
return error;

View File

@ -766,8 +766,7 @@ Model::SetLinkTo(Model *model)
ASSERT(IsSymLink());
ASSERT(!fLinkTo || (fLinkTo != model));
if (fLinkTo)
delete fLinkTo;
delete fLinkTo;
fLinkTo = model;
}

View File

@ -409,8 +409,8 @@ void
OffscreenBitmap::NewBitmap(BRect bounds)
{
delete fBitmap;
fBitmap = new BBitmap(bounds, B_RGB32, true);
if (fBitmap->Lock()) {
fBitmap = new(std::nothrow) BBitmap(bounds, B_RGB32, true);
if (fBitmap && fBitmap->Lock()) {
BView *view = new BView(fBitmap->Bounds(), "", B_FOLLOW_NONE, 0);
fBitmap->AddChild(view);

View File

@ -30,5 +30,6 @@ int main(int argc, char **argv)
*p++ = (uint8_t)sum;
//lseek(fd, 0LL, SEEK_SET);
write(fd, &sector[512-2], 2);
close(fd);
return 0;
}

View File

@ -771,6 +771,7 @@ platform_add_boot_device(struct stage2_args *args, NodeList *devicesList)
BIOSDrive *drive = new(nothrow) BIOSDrive(gBootDriveID);
if (drive->InitCheck() != B_OK) {
dprintf("no boot drive!\n");
delete drive;
return B_ERROR;
}

View File

@ -58,7 +58,7 @@ struct file_cache_ref {
last_access[index] = isWrite ? -access : access;
}
inline off_t LastAccess(int32 index, bool isWrite)
inline off_t LastAccess(int32 index, bool isWrite) const
{
return isWrite ? -last_access[index] : last_access[index];
}

View File

@ -1933,8 +1933,7 @@ elf_load_user_image(const char *path, struct team *team, int flags,
status = B_OK;
error:
if (programHeaders)
free(programHeaders);
free(programHeaders);
_kern_close(fd);
return status;

View File

@ -796,6 +796,7 @@ _user_xsi_semget(key_t key, int numberOfSemaphores, int flags)
if (semaphoreSet == NULL || !semaphoreSet->InitOK()) {
TRACE_ERROR(("xsi_semget: failed to allocate a new xsi "
"semaphore set\n"));
delete semaphoreSet;
return ENOMEM;
}
atomic_add(&sXsiSemaphoreCount, numberOfSemaphores);

View File

@ -1495,16 +1495,14 @@ thread_exit(void)
TRACE(("thread_exit: thread %ld now a kernel thread!\n", thread->id));
}
if (threadDeathEntry != NULL)
free(threadDeathEntry);
free(threadDeathEntry);
// delete the team if we're its main thread
if (deleteTeam) {
team_delete_team(team, debuggerPort);
// we need to delete any death entry that made it to here
if (death != NULL)
delete death;
delete death;
}
state = disable_interrupts();

View File

@ -128,8 +128,7 @@ fixed_queue_init(fixed_queue *q, int size)
void
fixed_queue_destroy(fixed_queue *q)
{
if (q->table)
free(q->table);
free(q->table);
}

View File

@ -635,8 +635,10 @@ driver_settings_init(kernel_args *args)
if (settings->size != 0) {
handle->text = malloc(settings->size + 1);
if (handle->text == NULL)
if (handle->text == NULL) {
free(handle);
return B_NO_MEMORY;
}
memcpy(handle->text, settings->buffer, settings->size);
handle->text[settings->size] = '\0';
@ -782,6 +784,7 @@ load_driver_settings(const char *driverName)
#ifdef _KERNEL_MODE
mutex_unlock(&sLock);
#endif
close(file);
return NULL;
}

View File

@ -447,7 +447,7 @@ class DateMask {
bool IsComplete();
private:
inline uint32 Flag(uint8 type) { return 1UL << type; }
inline uint32 Flag(uint8 type) const { return 1UL << type; }
uint32 fMask;
};

View File

@ -335,8 +335,10 @@ scandir(const char* path, struct dirent*** _entryArray,
arrayCapacity *= 2;
newArray = realloc(array, arrayCapacity * sizeof(void*));
if (newArray == NULL)
if (newArray == NULL) {
free(copiedEntry);
goto error;
}
array = newArray;
}