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,
|
sp_line_reader_new (const gchar *contents,
|
||||||
gssize length)
|
gssize length)
|
||||||
{
|
{
|
||||||
SpLineReader *self;
|
SpLineReader *self = g_slice_new (SpLineReader);
|
||||||
|
|
||||||
g_return_val_if_fail (contents != NULL, NULL);
|
if (contents == NULL)
|
||||||
|
|
||||||
self = g_slice_new (SpLineReader);
|
|
||||||
|
|
||||||
if (length < 0)
|
|
||||||
length = strlen (contents);
|
|
||||||
|
|
||||||
if (contents != NULL)
|
|
||||||
{
|
{
|
||||||
self->contents = contents;
|
contents = "";
|
||||||
self->length = length;
|
length = 0;
|
||||||
self->pos = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else if (length < 0)
|
||||||
{
|
{
|
||||||
self->contents = NULL;
|
length = strlen (contents);
|
||||||
self->length = 0;
|
|
||||||
self->pos = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self->contents = contents;
|
||||||
|
self->length = length;
|
||||||
|
self->pos = 0;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user