# HG changeset patch # User Josef 'Jeff' Sipek # Date 1586536030 14400 # Node ID 12a3139a2bafabfe9ffda1fbdb596b094f30c255 # Parent 6e72f4b462c83e69e950654d45f46168a6271f14 sock: use atomic_cas_ptr correctly This bug was caused by incorrect documentation (already fixed). It resulted in us freeing the name on successful CAS and caching the freed pointer. Signed-off-by: Josef 'Jeff' Sipek diff -r 6e72f4b462c8 -r 12a3139a2baf sock.c --- a/sock.c Fri Apr 10 12:25:17 2020 -0400 +++ b/sock.c Fri Apr 10 12:27:10 2020 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2019 Josef 'Jeff' Sipek + * Copyright (c) 2016-2020 Josef 'Jeff' Sipek * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -60,7 +60,7 @@ goto unknown; } - if (atomic_cas_ptr(&cached, NULL, name) != name) + if (atomic_cas_ptr(&cached, NULL, name) != NULL) free(name); return cached;