Skip to content

[BUG] Segmentation fault in queue.c #1269

@Arash1381-y

Description

@Arash1381-y

Description

In the queue model (path : data_structures/queue/queue.c). dequeue won't work due to a simple bug on the last if clause of it. take a look:

head->next = NULL;

as you can see if we have only one variable in our queue on dequeue the HEAD will be null and assigning NULL to NULL->next will cause a segmentation fault.

Expected behavior

not to cause fault =)

Actual behavior

case segmentation fault

Possible fix

simply put line 65 in its above clause

Steps to reproduce

  1. call create
  2. enqueue anything you like
  3. dequeue it

Context

It just don't work =)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions