mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
line-reader: handle invalid parameters more gracefully
This silences coverity which doesn't handle return_if_fail() macros very well.
This commit is contained in:
@ -51,28 +51,22 @@ SpLineReader *
|
||||
sp_line_reader_new (const gchar *contents,
|
||||
gssize length)
|
||||
{
|
||||
SpLineReader *self;
|
||||
SpLineReader *self = g_slice_new (SpLineReader);
|
||||
|
||||
g_return_val_if_fail (contents != NULL, NULL);
|
||||
|
||||
self = g_slice_new (SpLineReader);
|
||||
|
||||
if (length < 0)
|
||||
length = strlen (contents);
|
||||
|
||||
if (contents != NULL)
|
||||
if (contents == NULL)
|
||||
{
|
||||
self->contents = contents;
|
||||
self->length = length;
|
||||
self->pos = 0;
|
||||
contents = "";
|
||||
length = 0;
|
||||
}
|
||||
else
|
||||
else if (length < 0)
|
||||
{
|
||||
self->contents = NULL;
|
||||
self->length = 0;
|
||||
self->pos = 0;
|
||||
length = strlen (contents);
|
||||
}
|
||||
|
||||
self->contents = contents;
|
||||
self->length = length;
|
||||
self->pos = 0;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user