ctdbd: Avoid leaking file descriptor if talloc fails
[obnox/ctdb.git] / server / ctdb_control.c
index a8771f317663be846679b8c57b5c5711c7ab4f0e..cd96e822b597f6464666701235358e27666b3da1 100644 (file)
@@ -52,7 +52,10 @@ int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata)
        fsize = ftell(f);
        rewind(f);
        outdata->dptr = talloc_size(outdata, fsize);
-       CTDB_NO_MEMORY(ctdb, outdata->dptr);
+       if (outdata->dptr == NULL) {
+               fclose(f);
+               CTDB_NO_MEMORY(ctdb, outdata->dptr);
+       }
        outdata->dsize = fread(outdata->dptr, 1, fsize, f);
        fclose(f);
        if (outdata->dsize != fsize) {